如何在Android中创建一个切换按钮点击的覆盖视图
我想在单击按钮时创建并覆盖视图。类似于在Whatsapp中单击微笑按钮 我已经创建了一个默认可见性为GONE的framelayout,并在smiley按钮上添加了一个onclick侦听器来切换其可见性 我的布局XML:如何在Android中创建一个切换按钮点击的覆盖视图,android,Android,我想在单击按钮时创建并覆盖视图。类似于在Whatsapp中单击微笑按钮 我已经创建了一个默认可见性为GONE的framelayout,并在smiley按钮上添加了一个onclick侦听器来切换其可见性 我的布局XML: <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_ali
<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>
我已经在SmileButton中添加了onClickListener,它可以切换聊天列表的可见性
除了一些定位问题,我不确定这是否是最好的方法。我想你可以使用上下文菜单:你能发布一些代码或描述更多一点你有什么样的问题?我会创建一个背景透明的对话框,在屏幕上绘制时动态调整/定位。上下文菜单强制用户选择。我希望覆盖视图看起来像原始视图的一部分。用户还应该能够通过单击“微笑”按钮来切换显示