我有一个登录界面,不同版本的应用程序具有不同的品牌标识。我需要在该屏幕的布局文件中将背景图像设置为不同的样式,因此我想指向顶级容器的不同样式。但我不太清楚如何实现。
我声明了一个类似于以下的可定义样式:
<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>
我做错了什么吗?这样可以吗?