1

截屏如何将 AppBar 背景扩展到状态栏?可能吗?

4

3 回答 3

3

call this in your onCreate();

getWindow().getDecorView()
        .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);

sets your view layout as full screen and makes status bar colo transparent, works for Api21 and above.

于 2016-02-27T15:30:52.077 回答
0

Edit: I originally posted a solution based on a external link, that is not working now. This was the code:

    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>

And set android:fitsSystemWindows to true

于 2016-02-27T15:30:00.683 回答
0

在 API30 之前,可以使用以下方式实现效果:

  1. 主题Theme.MaterialComponents.Light.NoActionBar
  2. 设置窗口标志:
        window.setFlags(
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
        )
  1. 用于android:fitsSystemWindows="true"顶部布局

我不知道 API30+ 的解决方案

于 2020-08-19T07:10:50.917 回答