Avoid height flickering in a block when hiding content with \only [duplicate]

When using a construction like the following, the height of the block changes between frames. This change distracts the audience from the content. How to fix the height of the block, so that it doesn't "flicker"?

\documentclass{beamer}
\title{MWE of flickering boxes}
\author{\textsc{Jon Doe}}
\begin{document}
\frame{\titlepage}
\section{Flickering boxheight}
\begin{frame}\frametitle{The upper box flickers}
\begin{block}{\only<1-2>{Examples:} \only<3>{Pausetext:}\only<4>{Examples again:}}<1-4>
\only<1-2,4>{\begin{itemize}
\item<1-2,4> Example 1
\item<2-,4> Example 2
\end{itemize}}
\only<3>{Oneliner}
\end{block}
\begin{block}{Another Box}<3->
\end{block}
\end{frame}
\end{document}


marked as duplicate by Ignasi, Thorsten, Claudio Fiandrino, user2478, lockstepApr 16 '13 at 8:13

From the beamer documentation (section 9.5 Dynamically Changing Text or Images, p 84):

You may sometimes wish to have some part of a frame change dynamically from slide to slide. On each slide of the frame, something different should be shown inside this area. You could achieve the effect of dynamically changing text by giving a list of \only commands like this:

\only<1>{Initial text.}
\only<2>{Replaced by this on second slide.}
\only<3>{Replaced again by this on third slide.}


The trouble with this approach is that it may lead to slight, but annoying differences in the heights of the lines, which may cause the whole frame to “wobble” from slide to slide. This problem becomes much more severe if the replacement text is several lines long.

To solve this problem, you can use two environments: overlayarea and overprint. The first is more flexible, but less user-friendly

Here's an option using overlayarea:

\documentclass{beamer}
\title{MWE of flickering boxes}
\author{\textsc{Jon Doe}}
\begin{document}
\frame{\titlepage}
\section{Flickering boxheight}
\begin{frame}
\frametitle{The upper box flickers}
\begin{overlayarea}{\linewidth}{5\baselineskip}
\begin{block}{\only<1-2>{Examples:}\only<3>{Pausetext:}\only<4>{Examples again:}}<1-4>
\only<1-2,4>{\begin{itemize}
\item<1-2,4> Example 1
\item<2-,4> Example 2
\end{itemize}}
\only<3>{Oneliner}
\end{block}
\end{overlayarea}
\begin{block}{Another Box}<3->

The overlay area was fixed to the entire \linewidth and has a height of 5\baselineskip.