【问题标题】:How to transparent status bar on kitkat with Toolbar and NavigationView如何使用 Toolbar 和 NavigationView 在 kitkat 上透明状态栏
【发布时间】:2015-10-09 14:46:19
【问题描述】:

我正在尝试在我的应用程序(运行Kitkat)上获得此代码正在运行的其他活动的这个精美设计:

 public static class AppUtils {

        public static void setTitleBarTint(Activity ac) {

            ac.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            SystemBarTintManager tintManager = new SystemBarTintManager(ac);
            tintManager.setStatusBarTintEnabled(true);
            tintManager.setStatusBarTintDrawable(ac.getResources().getDrawable(R.drawable.kitkat_status_bar));


        }
    }

但是在我的MainActivitynavigationview 和协调器布局等上,此代码不起作用并且错过了工具栏。

当然,我已经尝试过每个教程,例如:

http://blog.raffaeu.com/archive/2015/04/11/android-and-the-transparent-status-bar.aspx

或其他人...,但是,没有任何工作!

样式:

 <!-- Base application theme. -->
    <style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorPrimary">@color/ColorPrimary</item>
        <item name="colorAccent">@color/ColorAccent</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBarOverlay">true</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:colorButtonNormal">#FF9800</item>
        <!-- Customize your theme here. -->
    </style>

    <style name="Theme.MyTheme" parent="AppTheme">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    </style>

有没有办法解决这个问题?

【问题讨论】:

  • 您是否尝试设置边距顶部?

标签: android material-design android-toolbar


【解决方案1】:

将此添加到您的 styles.xml 文件中。

<style name="Theme.MyTheme" parent="Theme.MyTheme.Base">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>

【讨论】:

  • 感谢您的回复,我已经编辑了问题并添加了您所说的内容,请检查。另外,状态栏没有任何半透明
  • 我已经检查并更改为:android:theme="@style/Theme.MyTheme" 它正在处理 + 21api 但是,这是我在 kitkat 中的输出:i.imgur.com/53yQki6.png 所以,我该怎么办需要做什么?
  • 对不起。我的意思是 values-v19/styles.xml 让它在那里
猜你喜欢
  • 1970-01-01
  • 2016-04-18
  • 2015-11-03
  • 2015-08-06
  • 1970-01-01
  • 1970-01-01
  • 2014-03-18
  • 2015-01-21
  • 1970-01-01
相关资源
最近更新 更多