popupwindow弹出时点击外部不消失,并且下面的控件不可响应

按照大家正常显示的情况下我们设置两个属性

popupWindow.setOutsideTouchable(false);
popupWindow.setFocusable(false);

这个时候点击外部popupwindow不会消失,但是下面的控件仍可点击

这个时候我们可以通过让popupwindow充满屏幕,在引入的布局中设置透明度的方法,达到自己想要的效果

例如

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="0"    //设置为透明
        />

    <LinearLayout
        android:layout_width="700px"
        android:layout_height="500px"
        android:orientation="vertical"
        android:background="#ffffff"
        
        android:gravity="center"
        android:layout_centerInParent="true"
        >
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="正在更新"
        android:gravity="center"
        android:layout_marginTop="20dp"
        />
   
   
    </LinearLayout>

</RelativeLayout>

这样就达到了效果~

猜你喜欢

转载自blog.csdn.net/ZhangXuxiaoqingnian/article/details/82658429