Android弹窗:
在Android中弹出式菜单(以下称弹窗)是使用十分广泛一种菜单呈现的方式,弹窗为用户交互提供了便利。关于弹窗的实现大致有以下两种方式AlertDialog和PopupWindow;
两者的区别:AlertDialog弹窗在位置显示上是固定的,而PopupWindow则相对比较随意,能够在主屏幕上的任意位置显示;
今天就简单介绍一下,如何利用PopupWindow实现RecyclerView的自定义的弹窗布局;
使用步骤:
1.创建两个xml文件,一个mainactivity主布局,一个是popupwindow布局(因为我是在项目里写的,所以闲杂代码可能比较多):
主布局(在其写一个Button按钮,因为项目需要,我换成了ImageView):
android:id="@+id/score_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="#f0f0f0">
android:id="@+id/bttest"
android:layou