我正在尝试 Material Design。我在样式中创建了一个主题
在我的 AndroidManifest.xml 中,我包含了这个主题(
这里是模拟器的屏幕截图:
MyMaterialTheme
。
样式:
<resources>
<!-- Theme for the material design of the app -->
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base"></style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimaryApp</item>
<item name="colorPrimaryDark">@color/colorPrimaryDarkApp</item>
<item name="colorAccent">@color/colorAccentApp</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
在我的 AndroidManifest.xml 中,我包含了这个主题(
MyMaterialTheme
)。我可以确认我的主题已经应用,因为它已经使用了正确的颜色。我将 windowActionBar 分配为 false,并将 windowNoTitle 分配为 true,但当我运行应用时仍然看到 ActionBar 和标题。有人能指出我哪里出错了吗?<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/MyMaterialTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<!-- android:theme="@style/AppTheme.NoActionBar"> -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
这里是模拟器的屏幕截图:
![](https://istack.dev59.com/619FM.webp)
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"
我认为你应该将它们删除。顺便说一下,我尝试过这个:android:windowNoTitle
,但那没用。除非你要使用Java,比如:requestWindowFeature(Window.FEATURE_NO_TITLE);
- ʍѳђઽ૯ท