13
我有一个登录屏幕,对于我的应用程序的不同构建以不同的方式进行品牌标记。我需要背景图像在这个屏幕的布局文件中有所不同,所以我想指向顶级容器的不同样式。我在如何做到这一点上有点不知所措。如何引用自定义主题中的样式
我已经声明了一个设置样式类似:
<resources>
<declare-styleable name="ThemeBase">
<attr name="loginPageContainerStyle" format="reference" />
</declare-styleable>
</resources>
我对应用几个不同的主题,因为这样的:
<resources>
<style name="ThemeBase" parent="android:style/Theme.Light" />
<style name="ThemeOne" parent="ThemeBase">
<item name="loginPageContainerStyle">@style/loginPageContainerThemeOne</item>
</style>
<style name="ThemeTwo" parent="ThemeBase">
<item name="loginPageContainerStyle">@style/loginPageContainerThemeTwo</item>
</style>
</resources>
而且我已经定义了以下样式:
<resources>
<style name="loginPageContainerThemeOne">
<item name="android:background">@drawable/background_theme_one</item>
</style>
<style name="loginPageContainerThemeTwo">
<item name="android:background">@drawable/background_theme_two</item>
</style>
</resources>
最后是一个login.xml文件,如:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loginRoot"
style= [ ? WHAT GOES HERE ? ]
android:gravity="center_horizontal"
android:orientation="horizontal">
[ LAYOUT STUFF ... ]
</LinearLayout>
我做错了什么?这可以这样做吗?
Android主题和样式的很好的例子。只需要提及在AndroidManifest上的应用标签需要添加android:theme =“@ style/ThemeOne”或android:theme =“@ style/ThemeTwo”,这就是我们需要了解的主题 – Ragaisis
非常感谢。正是我在找什么。 – dentex