赞
踩
在项目中, app没有用原生的Dialog去弹起一个弹窗,在本地new 一个 PhoneWindow去实现dialog的功能,代码如下:
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.internal.policy.PhoneWindow;
@SuppressLint("StaticFieldLeak")
public class MyPopup implements Handler.Callback, XXXXXXXXXControl.OnXXXXXXXXXStatusListener {
private Handler mHandler = new Handler(this);
private Context mContext;
private WindowManager mWindowManager;
private Window mWindow;
private ViewGroup mParentLayout;
private TextView mTitleText;
private ImageView mIconImg;
private TextView mMessageText;
private FrameLayout mCustomLayout;
private Button mPositiveBtn;
private Button mNegativeBtn;
private static final int ACTION_POPUP_DISMISS = 1000;
private static final long DELAYED_POPUP_DISMISS = 0L;
private boolean mIsShowing;
private boolean mCancelable = true;
private long mAutoCancelDelayMillis;
private int mWidthType;
private DialogInterface.OnShowListener mShowListener;
private DialogInterface.OnDismissListener mDismissListener;
public MyPopup(Context context) {
mContext = context;
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
mWindow = new PhoneWindow(context.getApplicationContext());
mWindow.requestFeature(Window.FEATURE_NO_TITLE);
mWindow.setContentView(R.layout.popup);
mWindow.setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
mWindow.setBackgroundDrawable(new ColorDrawable(0x99000000));
mWindow.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
View rootLayout = mWindow.findViewById(R.id.layout_root);
mParentLayout = mWindow.findViewById(R.id.layout_content);
mTitleText = mWindow.findViewById(R.id.tv_title);
mIconImg = mWindow.findViewById(R.id.iv_icon);
mMessageText = mWindow.findViewById(R.id.tv_message);
mCustomLayout = mWindow.findViewById(R.id.layout_custom_view);
mPositiveBtn = mWindow.findViewById(R.id.btn_positive);
mNegativeBtn = mWindow.findViewById(R.id.btn_negative);
rootLayout.setOnClickListener(v -> {
if (mCancelable) {
hide();
}
});
}
@Override
public boolean handleMessage(Message message) {
if (message.what == ACTION_POPUP_DISMISS) {
hide();
}
return false;
}
@Override
public void onXXXXXXXXXStatusChanged() {
initPopupAlign();
}
private void initPopupAlign() {
if (!mIsShowing) {
return;
}
boolean isSsShow = isSsShow();
boolean isCenter = !isSsShow;
mWindow.setLayout(isCenter ? 1920 : 1280, 720);
mWindow.setGravity(isCenter ? Gravity.CENTER : Gravity.START);
if (isCenter) {
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
} else {
mWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
}
mWindowManager.updateViewLayout(mWindow.getDecorView(), mWindow.getAttributes());
}
private void initPopupWidth() {
int widthDimensId;
switch (mWidthType) {
case AlertDialog.DIALOG_WIDTH_TYPE_SMALL:
widthDimensId = com.android.internal.R.dimen.alert_dialog_width_min;
break;
case AlertDialog.DIALOG_WIDTH_TYPE_MIDDLE:
widthDimensId = com.android.internal.R.dimen.alert_dialog_width_mid;
break;
case AlertDialog.DIALOG_WIDTH_TYPE_BIG:
default:
widthDimensId = com.android.internal.R.dimen.alert_dialog_width_max;
break;
}
ViewGroup.LayoutParams layoutParams = mParentLayout.getLayoutParams();
layoutParams.width = mContext.getResources().getDimensionPixelSize(widthDimensId);
mParentLayout.setLayoutParams(layoutParams);
}
private void removePopupDismissMessage() {
if (mHandler.hasMessages(ACTION_POPUP_DISMISS)) {
mHandler.removeMessages(ACTION_POPUP_DISMISS);
}
}
private void initAutoCancelable() {
if (mAutoCancelDelayMillis != DELAYED_POPUP_DISMISS) {
removePopupDismissMessage();
mHandler.sendEmptyMessageDelayed(ACTION_POPUP_DISMISS, mAutoCancelDelayMillis);
}
}
private void requestWindowFocus() {
if (mParentLayout != null) {
mParentLayout.setFocusableInTouchMode(true);
mParentLayout.requestFocus();
}
}
public void show() {
mWindowManager.addView(mWindow.getDecorView(), mWindow.getAttributes());
mIsShowing = true;
notifyPopupShow();
initPopupAlign();
initPopupWidth();
initAutoCancelable();
requestWindowFocus();
onShow();
}
public void hide() {
if (!mIsShowing) {
return;
}
mWindowManager.removeView(mWindow.getDecorView());
mIsShowing = false;
notifyPopupHide();
onDismiss();
removePopupDismissMessage();
mParentLayout = null;
mTitleText = null;
mIconImg = null;
mMessageText = null;
mCustomLayout = null;
mPositiveBtn = null;
mNegativeBtn = null;
mWindowManager = null;
mWindow = null;
mContext = null;
mHandler = null;
}
public boolean isShowing() {
return mIsShowing;
}
public MyPopup setCancelable(boolean cancelable) {
mCancelable = cancelable;
return this;
}
public MyPopup setAutoCancelable(long autoCancelDelayMillis) {
mAutoCancelDelayMillis = autoCancelDelayMillis;
return this;
}
public MyPopup setWidthType(int widthType) {
mWidthType = widthType;
return this;
}
public MyPopup setTitle(String title) {
if (mTitleText != null) {
mTitleText.setVisibility(View.VISIBLE);
mTitleText.setText(title);
}
return this;
}
public MyPopup setIconType(int iconType) {
if (mIconImg != null) {
mIconImg.setVisibility(View.VISIBLE);
int iconResId;
switch (iconType) {
case AlertDialog.DIALOG_ICON_WARNING:
iconResId = com.android.internal.R.drawable.co_warning;
break;
case AlertDialog.DIALOG_ICON_QUESTION:
iconResId = com.android.internal.R.drawable.co_question;
break;
default:
case AlertDialog.DIALOG_ICON_EXCLAMATION:
case AlertDialog.DIALOG_ICON_DEFAULT:
iconResId = com.android.internal.R.drawable.co_info;
break;
}
mIconImg.setImageResource(iconResId);
}
return this;
}
public MyPopup setMessage(String message) {
if (mMessageText != null) {
mMessageText.setVisibility(View.VISIBLE);
mMessageText.setText(message);
}
return this;
}
public MyPopup setCustomView(View view) {
if (mCustomLayout != null) {
mCustomLayout.setVisibility(View.VISIBLE);
mCustomLayout.removeAllViews();
if (view != null) {
mCustomLayout.addView(view);
}
}
return this;
}
public MyPopup setPositiveButton(String btnText, View.OnClickListener listener) {
if (mPositiveBtn != null) {
mPositiveBtn.setVisibility(View.VISIBLE);
mPositiveBtn.setText(btnText);
mPositiveBtn.setOnClickListener(v -> {
hide();
if (listener != null) {
listener.onClick(mPositiveBtn);
}
});
}
return this;
}
public MyPopup setNegativeButton(String btnText, View.OnClickListener listener) {
if (mNegativeBtn != null) {
mNegativeBtn.setVisibility(View.VISIBLE);
mNegativeBtn.setText(btnText);
mNegativeBtn.setOnClickListener(v -> {
hide();
if (listener != null) {
listener.onClick(mNegativeBtn);
}
});
}
return this;
}
public MyPopup setOnShowListener(DialogInterface.OnShowListener showListener) {
mShowListener = showListener;
return this;
}
private void onShow() {
if (mShowListener != null) {
mShowListener.onShow(null);
}
}
public MyPopup setOnDismissListener(DialogInterface.OnDismissListener dismissListener) {
mDismissListener = dismissListener;
return this;
}
private void onDismiss() {
if (mDismissListener != null) {
mDismissListener.onDismiss(null);
}
}
public MyPopup setOnKeyListener(View.OnKeyListener keyListener) {
if (mParentLayout != null) {
mParentLayout.setOnKeyListener(keyListener);
}
return this;
}
private void notifyPopupShow() {
// todo ...
}
private void notifyPopupHide() {
// todo ...
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/co_bg_popup"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv_title"
android:layout_width="0dp"
android:layout_height="60dp"
android:background="@drawable/co_bg_popup_title"
android:gravity="center"
android:textColor="@color/text_title"
android:textSize="26sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:src="@android:drawable/ic_dialog_info"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tv_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="20dp"
android:gravity="center"
android:textColor="@color/text_title"
android:textSize="26sp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/btn_positive"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_icon" />
<FrameLayout
android:id="@+id/layout_custom_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/btn_positive"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title" />
<Button
android:id="@+id/btn_positive"
android:layout_width="0dp"
android:layout_height="52dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/co_bt_bottom"
android:textAllCaps="false"
android:textColor="@color/popup_button_font_color"
android:textSize="26sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btn_negative"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btn_negative"
android:layout_width="0dp"
android:layout_height="52dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/co_bt_bottom"
android:textAllCaps="false"
android:textColor="@color/popup_button_font_color"
android:textSize="26sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/btn_positive" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
用上面可以做出Dialog的效果,但是当弹窗起来的时候statusbar不置灰, 因此在构造方法里,向SystemUI这个app里添加一个flag mWindow.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
去通知statusbar去置灰.
目前这个出现问题, 因为两个置灰的时间不一致,导致了在statusbar和弹窗后面的看起不一致,影响用户体验.
修改, 尝试修改,不使用new PhoneWindow(),直接创建一个window,然后将其add上去, 看代码
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManagerImpl;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.internal.policy.PhoneWindow;
@SuppressLint("StaticFieldLeak")
public class MyPopup implements Handler.Callback, XXXXXXXXXControl.OnXXXXXXXXXStatusListener {
private Handler mHandler = new Handler(this);
private Context mContext;
private WindowManager mWindowManager;
private Window mWindow;
private ViewGroup mParentLayout;
private TextView mTitleText;
private ImageView mIconImg;
private TextView mMessageText;
private FrameLayout mCustomLayout;
private Button mPositiveBtn;
private Button mNegativeBtn;
private static final int ACTION_POPUP_DISMISS = 1000;
private static final long DELAYED_POPUP_DISMISS = 0L;
private SplitScreenControl mSplitScreenControl;
private VRObserver mVRObserver;
private boolean mIsShowing;
private boolean mCancelable = true;
private long mAutoCancelDelayMillis;
private int mWidthType;
private DialogInterface.OnShowListener mShowListener;
private DialogInterface.OnDismissListener mDismissListener;
private View mView;
private WindowManagerImpl wm;
private WindowManager.LayoutParams mWindowLayoutParams;
public MyPopup(Context context) {
mContext = context;
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// mWindow = new PhoneWindow(context.getApplicationContext());
// mWindow.requestFeature(Window.FEATURE_NO_TITLE);
// mWindow.setContentView(R.layout.popup);
// mWindow.setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
// mWindow.setBackgroundDrawable(new ColorDrawable(0x99000000));
// mWindow.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = (View) inflater.inflate(R.layout.popup, null);
View rootLayout = mView.findViewById(R.id.layout_root);
mParentLayout = mView.findViewById(R.id.layout_content);
mTitleText = mView.findViewById(R.id.tv_title);
mIconImg = mView.findViewById(R.id.iv_icon);
mMessageText = mView.findViewById(R.id.tv_message);
mCustomLayout = mView.findViewById(R.id.layout_custom_view);
mPositiveBtn = mView.findViewById(R.id.btn_positive);
mNegativeBtn = mView.findViewById(R.id.btn_negative);
rootLayout.setOnClickListener(v -> {
if (mCancelable) {
hide();
}
});
}
private void addViewToWindowManager(View view) {
Log.i("liuhu", "MyTestWindow - addViewToWindowManager");
if (!mIsShowing) {
return;
}
boolean isSsShow = isSsShow();
boolean isSsOsdShow = isSsOsdShow();
boolean isCenter = !isSsShow && !isSsOsdShow;
wm = (WindowManagerImpl)mContext.getSystemService(Context.WINDOW_SERVICE);
int flags = 0;
flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
isCenter ? 1920 : 1280,
WindowManager.LayoutParams.MATCH_PARENT,
0,
0,
WindowManager.LayoutParams.TYPE_MY_TEST_DIALOG, // 自己选一个层级
flags,
PixelFormat.TRANSPARENT);
lp.setTitle("MyTestWindow");
lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
lp.gravity = Gravity.LEFT;
mWindowLayoutParams = lp;
wm.addView(view, lp);
}
private void changeWindowSize() {
Log.d("liuhu", "MyTestWindow - changeWindowSize");
if (!mIsShowing && mView != null) {
return;
}
boolean isSsShow = isSsShow();
boolean isCenter = !isSsShow;
mWindowLayoutParams.width = isCenter ? 1920 : 1280;
wm.updateViewLayout(mView, mWindowLayoutParams);
}
private void removeViewToWindowManager(View view) {
Log.i("liuhu", "MyTestWindow - removeViewToWindowManager");
wm = (WindowManagerImpl)mContext.getSystemService(Context.WINDOW_SERVICE);
wm.removeView(view);
}
@Override
public boolean handleMessage(Message message) {
if (message.what == ACTION_POPUP_DISMISS) {
hide();
}
return false;
}
@Override
public void onXXXXXXXXStatusChanged() {
changeWindowSize();
}
private void initPopupAlign() {
if (!mIsShowing) {
return;
}
boolean isSsShow = isSsShow();
boolean isSsOsdShow = isSsOsdShow();
boolean isCenter = !isSsShow && !isSsOsdShow;
mWindow.setLayout(isCenter ? 1920 : 1280, 720);
mWindow.setGravity(isCenter ? Gravity.CENTER : Gravity.START);
if (isCenter) {
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
} else {
mWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
}
mWindowManager.updateViewLayout(mWindow.getDecorView(), mWindow.getAttributes());
}
private void initPopupWidth() {
int widthDimensId;
switch (mWidthType) {
case AlertDialog.DIALOG_WIDTH_TYPE_SMALL:
widthDimensId = com.android.internal.R.dimen.alert_dialog_width_min;
break;
case AlertDialog.DIALOG_WIDTH_TYPE_MIDDLE:
widthDimensId = com.android.internal.R.dimen.alert_dialog_width_mid;
break;
case AlertDialog.DIALOG_WIDTH_TYPE_BIG:
default:
widthDimensId = com.android.internal.R.dimen.alert_dialog_width_max;
break;
}
ViewGroup.LayoutParams layoutParams = mParentLayout.getLayoutParams();
layoutParams.width = mContext.getResources().getDimensionPixelSize(widthDimensId);
mParentLayout.setLayoutParams(layoutParams);
}
private void removePopupDismissMessage() {
if (mHandler.hasMessages(ACTION_POPUP_DISMISS)) {
mHandler.removeMessages(ACTION_POPUP_DISMISS);
}
}
private void initAutoCancelable() {
if (mAutoCancelDelayMillis != DELAYED_POPUP_DISMISS) {
removePopupDismissMessage();
mHandler.sendEmptyMessageDelayed(ACTION_POPUP_DISMISS, mAutoCancelDelayMillis);
}
}
private void requestWindowFocus() {
if (mParentLayout != null) {
mParentLayout.setFocusableInTouchMode(true);
mParentLayout.requestFocus();
}
}
public void show() {
// mWindowManager.addView(mWindow.getDecorView(), mWindow.getAttributes());
if (mView!=null) {
mIsShowing = true;
notifyPopupShow();
// initPopupAlign();
addViewToWindowManager(mView);
initPopupWidth();
initAutoCancelable();
requestWindowFocus();
onShow();
}
}
public void hide() {
if (!mIsShowing) {
return;
}
// mWindowManager.removeView(mWindow.getDecorView());
removeViewToWindowManager(mView);
mIsShowing = false;
notifyPopupHide();
onDismiss();
removePopupDismissMessage();
mParentLayout = null;
mTitleText = null;
mIconImg = null;
mMessageText = null;
mCustomLayout = null;
mPositiveBtn = null;
mNegativeBtn = null;
mWindowManager = null;
mWindow = null;
mContext = null;
mHandler = null;
mView = null;
wm = null;
mWindowLayoutParams = null;
}
public boolean isShowing() {
return mIsShowing;
}
public MyPopup setCancelable(boolean cancelable) {
mCancelable = cancelable;
return this;
}
public MyPopup setAutoCancelable(long autoCancelDelayMillis) {
mAutoCancelDelayMillis = autoCancelDelayMillis;
return this;
}
public MyPopup setWidthType(int widthType) {
mWidthType = widthType;
return this;
}
public MyPopup setTitle(String title) {
if (mTitleText != null) {
mTitleText.setVisibility(View.VISIBLE);
mTitleText.setText(title);
}
return this;
}
public MyPopup setIconType(int iconType) {
if (mIconImg != null) {
mIconImg.setVisibility(View.VISIBLE);
int iconResId;
switch (iconType) {
case AlertDialog.DIALOG_ICON_WARNING:
iconResId = com.android.internal.R.drawable.co_ic_battery_warning;
break;
case AlertDialog.DIALOG_ICON_QUESTION:
iconResId = com.android.internal.R.drawable.co_ic_question;
break;
default:
case AlertDialog.DIALOG_ICON_EXCLAMATION:
case AlertDialog.DIALOG_ICON_DEFAULT:
iconResId = com.android.internal.R.drawable.co_ic_info;
break;
}
mIconImg.setImageResource(iconResId);
}
return this;
}
public MyPopup setMessage(String message) {
if (mMessageText != null) {
mMessageText.setVisibility(View.VISIBLE);
mMessageText.setText(message);
}
return this;
}
public MyPopup setCustomView(View view) {
if (mCustomLayout != null) {
mCustomLayout.setVisibility(View.VISIBLE);
mCustomLayout.removeAllViews();
if (view != null) {
mCustomLayout.addView(view);
}
}
return this;
}
public MyPopup setPositiveButton(String btnText, View.OnClickListener listener) {
if (mPositiveBtn != null) {
mPositiveBtn.setVisibility(View.VISIBLE);
mPositiveBtn.setText(btnText);
mPositiveBtn.setOnClickListener(v -> {
hide();
if (listener != null) {
listener.onClick(mPositiveBtn);
}
});
}
return this;
}
public MyPopup setNegativeButton(String btnText, View.OnClickListener listener) {
if (mNegativeBtn != null) {
mNegativeBtn.setVisibility(View.VISIBLE);
mNegativeBtn.setText(btnText);
mNegativeBtn.setOnClickListener(v -> {
hide();
if (listener != null) {
listener.onClick(mNegativeBtn);
}
});
}
return this;
}
public MyPopup setOnShowListener(DialogInterface.OnShowListener showListener) {
mShowListener = showListener;
return this;
}
private void onShow() {
if (mShowListener != null) {
mShowListener.onShow(null);
}
}
public MyPopup setOnDismissListener(DialogInterface.OnDismissListener dismissListener) {
mDismissListener = dismissListener;
return this;
}
private void onDismiss() {
if (mDismissListener != null) {
mDismissListener.onDismiss(null);
}
}
public MyPopup setOnKeyListener(View.OnKeyListener keyListener) {
if (mParentLayout != null) {
mParentLayout.setOnKeyListener(keyListener);
}
return this;
}
private void notifyPopupShow() {
// todo ...
}
private void notifyPopupHide() {
// todo ...
}
}
这样修改,当弹窗起来,底层是没有置灰的效果的,需要修改popup.xml文件的
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99000000">
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。