今天我们来了解一下Android中的弹窗之PopupWindow的使用:
如下图:当我们要点击右上角的菜单时弹出的弹窗:实现这个效果我们分三步:
1:首先新建一个弹窗的XML文件X.xml代码如下(R.layout.pop_diary_detail):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99444444"
android:fitsSystemWindows="true"
android:gravity="center|bottom"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="13dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="340dp"
android:layout_height=