Android Studio-如何具有透明的状态栏?

问题描述 投票:0回答:1

描述:

这是在此网站上提出的问题,但是答案对我没有帮助。我只需要使状态栏透明,这就是我发现的内容:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

我已经尝试过并且可以正常工作,但是它也使底部操作栏也透明(对于底部操作栏,我是说:)

enter image description here

如何使顶部状态栏仅透明?

非常感谢您阅读

android android-studio statusbar
1个回答
0
投票

您可以创建用于设置状态栏颜色的自定义主题。它适用于版本21及更高版本:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
         <!-- You can customize it by changing statusBarColor. -->
        <item name="android:statusBarColor">@color/pieces_cherry</item>
</style>

并且在清单中,您需要将其设置为您的应用主题

© www.soinside.com 2019 - 2024. All rights reserved.