1. 清单文件声明权限
<!-- 显示顶层浮窗 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
2. 全局的PopupWindow的布局文件(total_popup_window.xml ) :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center"
android:background="#ededed"
android:gravity="center"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/popup_window"
android:layout_width="300dp"
android:layout_height="200dp"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="44dp"
android:gravity="center"
android:text="标题"
android:textColor="#000000"
android:textSize="18sp" />
<View
android:id="@+id/title_divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/title"
android:background="#ededed" />
<TextView
android:id="@+id/content"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/title_divi