How to create an overlay view in Android which toggles on button click
<p>I want to create and overlay view when a button is clicked. Something like clicking smileys button in Whatsapp.</p>

<blockquote>
  <p>I have created a framelayout with default visibility as GONE and added an onclick listener on  smiley button to toggle its visibility.</p>
</blockquote>

<p>My layout XML:</p>

<pre><code>       &lt;RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true" &gt;

        &lt;ImageView
            android:id="@+id/smileyButton"
            android:layout_width="24dip"
            android:layout_height="48dip"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:contentDescription="@string/contactIconContentDescription"
            android:src="@drawable/emo_im_happy" /&gt;

        &lt;FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/smileyButton" &gt;

            &lt;TextView
                android:id="@+id/chat_smiley_list"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@android:color/white" /&gt;
        &lt;/FrameLayout&gt;
    &lt;/RelativeLayout&gt;
</code></pre>

<p>I have added onClickListener to smileyButton which toggles visibility of chat_smiley_list.</p>

<p>Other than some positioning problems, I am not sure whether this is the best way to do it.</p>
