アプリケーションのビルドごとに異なるブランドのログイン画面があります。この画面のレイアウト ファイルでは背景画像を異なるものにする必要があるため、トップ レベルのコンテナーに対して別のスタイルを指定したいと考えています。私はこれを行う方法に少し途方に暮れています。
次のようなスタイル可能なものを宣言しました。
<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>
私は何か間違ったことをしていますか?これはこのように行うことができますか?