【发布时间】:2015-04-29 15:45:43
【问题描述】:
我有 2 个活动: Activity1 , Activity2
Activity1的主题是蓝色,另一个是橙色
现在我有一个在这些活动中膨胀的 xml 布局 (sort_items.xml)
我想在我打开 Activity1 时将此布局的背景颜色设为蓝色,并在我打开 Activity2 时设为橙色。
我在styles.xml中创建了2个样式:
<style name="AppThemeOrange"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyActionBarOrange</item>
</style>
<style name="AppThemeBlue"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyActionBarBlue</item>
</style>
这些主题归因于它们在 manifest.xml 中的活动
colors.xml 中也有两种颜色
<color name="orange">#ffa726</color>
<color name="blue">#119eff</color>
这是 sort_items.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="???"
android:id="@+id/layout1">
...
</LinearLayout>
现在如何设置在每个活动中自动更改的 layout1(在 sort_items.xml 中)背景颜色?
谢谢。
【问题讨论】: