我将appcompat-v7更新为lollipop版本(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版本时,操作栏将按预期隐藏。
如何使用AppCompat
版本21库隐藏自定义样式的操作栏?
答案 0 :(得分:34)
@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日
升级到android:windowNoTitle
windowNoTitle
替换为AppCompat v22.1.0
答案 1 :(得分:10)
好的,我找到了答案。
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>
android
属性中没有windowActionBar
前缀。