【问题标题】:Trouble with tabs and translucent statusbar/navigation for android 4.4android 4.4 的标签和半透明状态栏/导航出现问题
【发布时间】:2014-01-17 12:23:33
【问题描述】:

我想为我的应用程序(用于 kitkat)添加半透明状态栏和导航,并且在大多数地方都可以正常工作。

我有一个主题:

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

在我的布局中我有android:fitsSystemWindows="true"

对于正常活动,这可以正常工作,但我有两个活动会造成麻烦。 -> 内容显示在状态栏和我的操作栏后面。

其中一个是 PreferenceActivity,我通过添加 findViewById(android.R.id.list).setFitsSystemWindows(true); 修复了它

第二个是带有ActionBar.NAVIGATION_MODE_TABS 的活动,我找不到setFitsSystemWindows(true) 调用的正确目标。

我尝试使用 findViewById(android.R.id.content)findViewById(android.R.id.tabcontent)。我还尝试将 xml 属性添加到片段的布局中,但没有成功。

【问题讨论】:

  • 这里没有答案,只有一个问题。在您的偏好活动中,您是否使状态栏与您的操作栏颜色相同?我试图弄清楚如何在不使整个 PreferenceActivity 具有相同颜色的情况下做到这一点。
  • 因为我从来没有解决这个问题,所以我决定根本不改变状态栏(现在)。所以我不知道你怎么能做到这一点,对不起。
  • 您找到解决方案了吗?请分享!
  • 我找到了这个,希望对您有所帮助:https://github.com/Takhion/android-extendedactionbar
  • 所以我最终使用了 PreferenceFragment 和 SystemBarTintManager 并且效果很好。 github.com/jgilfelt/SystemBarTint

标签: android statusbar android-4.4-kitkat


【解决方案1】:

在您的工具栏上添加一个 25 dp 的 paddingTop

【讨论】:

  • 不错的技巧。不要忘记调整工具栏的高度,以防您使用 ?android:attr/actionBarSize 56 dp,因此最终高度将是 56 + 16dp == android:layout_height="72dp"
猜你喜欢
  • 2014-12-15
  • 1970-01-01
  • 1970-01-01
  • 2017-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-01
相关资源
最近更新 更多