android状态栏怎么设置透明

2024-10-23 19:42:15

1、在Style.xml文件中设置:<item name="android:windowTranslucentStatus">true</item> //透明的状态栏 <item name="android:windowTranslucentNavigation">true</item>//透明的导航图 <item name="android:fitsSystemWindows">true</item>//设置应用布局时是否考虑系统窗口布局

android状态栏怎么设置透明

3、使用代码设置(判断当前SDK是否大于19,推荐使用代码设置)//判断SDK版本是否大于等于4.4 因为该属性只有19版本才能设置if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);}

android状态栏怎么设置透明
猜你喜欢