Dialog弹出Activity及设置是否可点击view外区域
让activity以dialog方式弹出
<activity
android:name=".activity.xxxxxActivity"
android:theme="@style/DialogTheme"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
方法一:在android:theme="@style/DialogTheme"加入android:windowCloseOnTouchOutside
<style name="DialogTheme" parent="@android:Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/white</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowCloseOnTouchOutside">false</item> //是否可以点击view外区域
</style>
方法二:在初始化activity时加入,setCanceledOnTouchOutside(false)设置点击空白处不消失
如果能取到dialog对象可直接设置
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);