1.要实现这种效果
2.可以使用这种方式
View v = LayoutInflater.from(mContext).inflate(R.layout.ceshi_01, null);
PopupWindow popupWindow = new PopupWindow(v, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
popupWindow.showAsDropDown(v);
v.findViewById(R.id.ig).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("111333", "用户点击了关闭");
popupWindow.dismiss();
}
});
3.ceshi_01的布局代码如下。布局中的图片可以换成自己的图片
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="1080dp"
android:layout_height="1920dp"
android:background="#00000000"
android:orientation="vertical">
<LinearLayout
android:id="@+id/yyy"
android:layout_width="900dp"
android:layout_height="1125dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="375dp"
android:background="@drawable/qd_01"
android:orientation="vertical">
</LinearLayout>
<ImageView
android:id="@+id/ig"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_below="@id/yyy"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:background="@color/blue"
app:srcCompat="@drawable/icon" />
</LinearLayout>
4.drawable/qd_01下的文件内容如下
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="900dp" android:height="1125dp">
<shape android:shape="rectangle">
<stroke android:width="2dp" android:color="#ff707070" />
<solid android:color="#fff2faff" />
<corners android:topLeftRadius="45dp" android:topRightRadius="45dp" android:bottomLeftRadius="45dp" android:bottomRightRadius="45dp" />
</shape>
</item>
</selector>
5.我画的效果图是这样
模拟器运行的效果图是这样的,是不是很像了
`