【问题标题】:Theme in android manifestandroid清单中的主题
【发布时间】:2018-02-03 15:00:01
【问题描述】:

如何组合

android:theme="@android:style/Theme.Material.Light"

和

android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"

在 android-manifest.xml 或 values/style.xml 中?

【问题讨论】:

  • 你所说的“混合”是什么意思?
  • 我的意思是我想结合这两个主题。有什么办法吗?
  • 已经有全屏材质灯主题了吧?
  • 删除了 xml 标签,因为它太宽泛了,添加了更精确的标签。略微改进的格式

标签: android android-manifest android-theme android-styles


【解决方案1】:

您需要从第二个获取相关属性并将它们添加到第一个。您可以通过扩展 styles.xml 中的第一个主题来做到这一点。

将 NoActionBar 添加到主题的示例如下:

 <!-- Base application theme. -->
    <style name="BaseTheme" 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" parent="BaseTheme"/>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
</style>

取自这里:

https://github.com/Austin-Android/austin-feeds-me/blob/master/app/src/main/res/values/styles.xml

【讨论】:

  • 哇!如果有帮助,请排除答案:)
【解决方案2】:

标签中只能扩展一个父级。您拥有第二个所需的样式属性并应用如下内容。

 <style name="Themelight" parent="Theme.AppCompat.Light">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@color/colorAccent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:background">@color/colorPrimary</item>
    <item name="android:windowFullscreen">true</item>
 </style>

样式继承相关参考android开发者文档https://developer.android.com/guide/topics/ui/look-and-feel/themes.html#Inheritance

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多