Android 应用程序未使用自定义主题
我想在我的应用程序中禁用ActionBar,我一直在寻找stackoverflow的解决方案,但没有任何帮助。我的问题是没有使用我的自定义主题NoActionBar,而是继续使用AppBaseTheme,尽管我在清单中更改了它:Android 应用程序未使用自定义主题,android,Android,我想在我的应用程序中禁用ActionBar,我一直在寻找stackoverflow的解决方案,但没有任何帮助。我的问题是没有使用我的自定义主题NoActionBar,而是继续使用AppBaseTheme,尽管我在清单中更改了它: android:theme="@style/NoActionBar" values-v14样式: <resources> <!-- Base application theme for API 14+. This theme complete
android:theme="@style/NoActionBar"
values-v14样式:
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="NoActionBar" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
与v11中的值相同。在“值”中,我添加了这一行,但我认为这不是必需的:
<style name="NoActionBar" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
</style>
我试图更改NoActionBar的父级,但没有成功。我试图为NoActionBar创建一个额外的.xml,但也没有成功,因为清单没有找到它。我试过stackoverflow问题中的其他技巧,但它们已经过时了。
我知道当我将这两个项目放在AppBaseTheme样式中时,它是可以工作的,但我很确定这不是正确的使用方法
简言之:
有人能给我解释一下为什么不使用我的主题吗?什么主题需要哪位家长?我如何定义多个主题
我希望我能正确地解释它,我假设答案很简单,为我的语言错误提前道歉,我不是本地人。谢谢
编辑清单:
您正在使用您的主题,但您的父对象不能是AppBaseTheme,您必须将其用作父对象,例如theme.Holo.NoActionBar或至少是不带操作栏的样式。非常感谢!我认为这可能是问题所在,但如果另一个主题需要ActionBar,而BaseTheme没有呢?@somecreativeusername您只需创建另一个具有正确父级的主题,并在清单的“活动”部分中使用android:Theme属性为每个需要使用它的活动指定该主题即可。
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/NoActionBar" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>