【发布时间】:2011-10-05 06:28:06
【问题描述】:
我有一个 Activity,它在清单中设置了样式资源(使用 android:theme="@style/blah"。我希望在 Java 代码中动态更改此 Activity 的背景颜色。我该怎么做?
谢谢!
【问题讨论】:
标签: android android-activity background themes styles
我有一个 Activity,它在清单中设置了样式资源(使用 android:theme="@style/blah"。我希望在 Java 代码中动态更改此 Activity 的背景颜色。我该怎么做?
谢谢!
【问题讨论】:
标签: android android-activity background themes styles
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/activityRootContainer>
</FrameLayout>
然后在你的代码中:
findViewById(R.id.activityRootContainer).setBackgroundDrawable(getResources().getDrawable(R.drawable.backgroundImage))
或
findViewById(R.id.activityRootContainer).setBackgroundColor(Color.RED)
HTH?
【讨论】: