I want to create and overlay view when a button is clicked. Something like clicking smileys button in Whatsapp.
I have created a framelayout with default visibility as GONE and added an onclick listener on smiley button to toggle its visibility.
My layout XML:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<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" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/smileyButton" >
<TextView
android:id="@+id/chat_smiley_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white" />
</FrameLayout>
</RelativeLayout>
I have added onClickListener to smileyButton which toggles visibility of chat_smiley_list.
Other than some positioning problems, I am not sure whether this is the best way to do it.
I think you could use a Context Menu: documentation