<style name="FullScreenDialogTheme" parent="Theme.AppCompat.Dialog">
<!-- 上面說過,只要是Dialog,這兩個屬性必須設(shè)置 -->
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<!--設(shè)置透明狀態(tài)欄,適用于SDK19(4.4)及以上版本-->
<item name="android:windowTranslucentStatus" >true</item>
<!-- 如果你不需要自定義狀態(tài)欄顏色,下面兩個可不要 -->
<item name="android:windowDrawsSystemBarBackgrounds" >true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<!-- 透明導(dǎo)航欄 -->
<item name="android:windowTranslucentNavigation">true</item>
</style>
public class FullPhotoDialog extends DialogFragment {
@NonNull
@NotNull
@Override
public Dialog onCreateDialog(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
setStyle(STYLE_NORMAL, R.style.FullScreenDialogTheme);
Dialog dialog = super.onCreateDialog(savedInstanceState);
Window window = dialog.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.getDecorView().setPadding(0, 0, 0, 0);
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
return dialog;
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。