【问题标题】:how to use 2 android themes in android manifist?如何在 android manifest 中使用 2 个 android 主题?
【发布时间】:2014-07-10 16:49:20
【问题描述】:
我尝试在一个活动中使用 2 个主题,一个用于对话框,一个用于隐藏标题栏,在 AndroidManifest 中:
android:theme="@android:style/Theme.Dialog"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:label="@string/app_name" > (it show X here!!)
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我一次只能使用一个...
【问题讨论】:
标签:
android-manifest
android-theme
【解决方案1】:
制作一个自定义主题并在其中应用您想要的所有样式,并将该主题设置为清单或活动的主题。例如:
在 values 文件夹中创建一个名为 customtheme.xml 的 xml 文件,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CustomTheme" parent="AppBaseTheme">
<item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground </item>
<item name="android:windowTitleSize">@dimen/custom_title_bar_h</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="ptrHeaderStyle">@style/Widget.Custom.PtrHeader</item>
<!-- <item name="popupMenuStyle">@style/PopupMenu</item>
<item name="textAppearanceLargePopupMenu">@style/myPopupMenuTextAppearanceLarge</item>
<item name="textAppearanceSmallPopupMenu">@style/myPopupMenuTextAppearanceSmall</item> -->
</style>
<style name="WindowTitleBackground">
<item name="android:padding">0px</item>
<item name="android:background">@drawable/action_bar_bg</item>
</style>
<style name="Widget.Custom.PtrHeader" parent="android:Widget">
<!-- The background of the header view -->
<item name="ptrHeaderBackground">@drawable/action_bar_bg</item>
<!-- The height of the header view. Please note, only set if in you really need to -->
<item name="ptrHeaderHeight">@dimen/custom_title_bar_h</item>
<item name="ptrHeaderTitleTextColor">@color/white</item>
</style>
</resources>
现在将该主题设置为您的活动:
<activity
android:name=".SettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/CustomTheme" >
</activity>