private void showPopwindowMenu(Activity activity) {
View popView = View.inflate(this, R.layout.reset_pwd_sure, null);
TextView btn = (TextView) popView
.findViewById(R.id.tv_sure);
int width = getResources().getDisplayMetrics().widthPixels;
int height = getResources().getDisplayMetrics().heightPixels;
final PopupWindow popWindow = new PopupWindow(popView, width, height);
popWindow.setFocusable(true);
popWindow.setOutsideTouchable(false);// 设置允许在外点击消失
View.OnClickListener listener = new View.OnClickListener() {
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_sure:
startActivity(new Intent(ForgetPwdResetActivity.this, PwdLoginActivity.class));
overridePendingTransition(R.anim.leftin, R.anim.leftout);
break;
}
popWindow.dismiss();
}
};
btn.setOnClickListener(listener);
// 设置好参数之后再show
popWindow.showAtLocation(activity.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
}
reset_pwd_sure.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80000000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:background="@drawable/forget_pwd_reset"
android:orientation="vertical"
android:layout_height="120dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_reset_sure"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="40dp"
android:src="@mipmap/reset_sure"
/>
<TextView
android:id="@+id/tv_reset_sure"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/iv_reset_sure"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:text="密码重置成功,请重新登陆"
android:textColor="#ff999999"
android:textSize="17sp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_below="@+id/iv_reset_sure"
android:layout_marginTop="10dp"
android:layout_alignParentBottom="true"
android:layout_height="60dp">
<TextView
android:id="@+id/tv_sure"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#383838"
android:textSize="17sp"
android:clickable="true"
android:layout_gravity="center"
android:text="@string/sure"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>