我有以下主题res/values/styles.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="@android:style/Theme.NoTitleBar">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
</style>
</resources>
如果我删除该<item name="android:windowNoTitle">true</item>
行,我的活动就会有标题栏。但是,如果我将那条线保留在那里,那么它们就没有标题栏(这是我想要的)。
我很好奇为什么parent="@android:style/Theme.NoTitleBar"
似乎没有效果?parent
不做我认为的事情?我认为它是这样工作的:
@android:style/Theme.NoTitleBar --> AppBaseTheme --> AppTheme
^ ^ ^
| | |
| | Has everything AppBaseTheme
| | does, unless it's overridden
| |
| Has everything @android:style/Theme.NoTitleBar
| does, unless it's overridden (which I'm not
| doing)
|
Sets whatever it needs to to not have a title, which I assume
is done by setting <item name="android:windowNoTitle">true</item>
但是,我也发现如果我设置<item name="android:windowNoTitle">true</item>
它AppBaseTheme
也没有效果;我必须将它设置在AppTheme
. 那么指定父级到底有什么意义呢?