【问题标题】:android:windowNoTitle will not hide actionbar with appcompat-v7 21.0.0android:windowNoTitle 不会使用 appcompat-v7 21.0.0 隐藏操作栏
【发布时间】:2014-11-12 02:44:35
【问题描述】:

我将 appcompat-v7 更新为棒棒糖版本(21.0.0)

那么我无法使用以前有效的以下样式隐藏 ActionBar。

<style name="AppTheme.NoActionBar">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

我将其设置为特定活动。

<activity android:name=".NoActionBarActivity"
        android:theme="@style/AppTheme.NoActionBar"/>

当我使用 appcompat-v7 20.0.0 版本时,actionbar 将按预期隐藏。

如何使用 AppCompat 版本 21 库隐藏具有自定义样式的操作栏?

【问题讨论】:

  • “效果很好”是什么意思?您的问题没有描述您想要实现的目标。
  • 我的意思是如果我使用版本 20,actionbar 将被隐藏。

标签: android android-5.0-lollipop android-appcompat


【解决方案1】:

@Chk0nDanger你的回答是对的,但你应该使用下面的代码:

<style name="Theme.AppCompat.NoActionBar" parent="Theme.AppCompat.Light">
   <item name="windowActionBar">false</item>
   <item name="android:windowNoTitle">true</item>
</style> 

没有父元素,一切都将是白色(textviews,buttons,chekcboxs 等)!

在您的manifest.xml 文件中:

    <activity android:name=".MyClass"
        android:theme="@style/Theme.AppCompat.NoActionBar"
        />

2015 年 7 月 29 日更新

确保升级到AppCompat v22.1.0android:windowNoTitle 应替换为windowNoTitle

【讨论】:

  • 确保在升级到 AppCompat v22.1.0android:windowNoTitle 应替换为 windowNoTitle
【解决方案2】:

好的,我找到了答案。

appcompat-v7:21.0.0 中有 Theme.AppCompat.NoActionBar 主题。 定义如下。

<style name="Theme.AppCompat.NoActionBar">
   <item name="windowActionBar">false</item>
   <item name="android:windowNoTitle">true</item>
</style>

windowActionBar 属性中没有 android 前缀。

【讨论】:

  • 一切都变成了白色!
猜你喜欢
  • 1970-01-01
  • 2014-12-31
  • 1970-01-01
  • 2015-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-14
  • 1970-01-01
相关资源
最近更新 更多