windowActionModeOverlay

windowActionModeOverlay:

android:windowActionModeOverlay=“true|false”  :

actionmode 弹出时覆盖部分布局      若 false 则不符盖,将原有布局下移

ActionMode用法链接:http://blog.csdn.net/xyz_lmn/article/details/12754785

 

转载于:https://www.cnblogs.com/butterfly-clover/p/windowActionModeOverlay.html

在Android 11及更高版本中,如果你想要隐藏状态栏,主要是为了全屏显示或者获得沉浸式体验,你可以通过修改Activity的主题或者使用AppCompatDelegate来实现。以下是步骤: 1. **修改主题**: - 在`styles.xml`文件中创建一个新的主题,设置窗口行为(WindowBehavior)为`DecorToolbar`: ```xml <style name="Theme.MyApp.NoActionBar" parent="Theme.MaterialComponents.Light.DarkActionBar"> <item name="windowNoTitle">true</item> <item name="android:statusBarColor">@android:color/transparent</item> <item name="windowActionModeOverlay">true</item> <item name="windowFullscreen">true</item> <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:statusBarIsLightContent">false</item> <!-- 如果需要区分亮暗模式 --> <item name="android:windowBehavior">@androidx.coordinatorlayout.widget.AppBarLayout$ScrollingViewBehavior</item> </style> ``` 然后在启动Activity时应用这个主题: ```java Intent intent = new Intent(this, YourActivity.class); intent.putExtra(BUNDLE_KEY, true); // 设置是否全屏 intent.setFlags(Intent.FLAG_ACTIVITY_NO_TITLE | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); ``` 2. **使用AppCompatDelegate**: - 在`onCreate()`方法中切换到无标题模式,并设置透明状态栏: ```java if (getIntent().hasExtra(BUNDLE_KEY)) { AppCompatDelegate.setDecorToolbar(findViewById(R.id.toolbar)); // 或者 toolbar 的 id AppCompatDelegate.setDefaultDisplayHomeAsUpEnabled(true); Window window = getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } ``` 记得在某些场景下(如系统回调或用户按下Home键),状态栏可能会暂时显示。此外,确保适配隐私政策的变化,如在API 30以上获取状态栏颜色权限。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值