1
我已经拥有一个样式资源在清单中设置一个活动(使用android:theme="@style/blah"
。我希望能够动态改变这个活动在Java代码中的背景颜色。我怎么会去这样做更改背景颜色基于一个主题/风格
感谢
我已经拥有一个样式资源在清单中设置一个活动(使用android:theme="@style/blah"
。我希望能够动态改变这个活动在Java代码中的背景颜色。我怎么会去这样做更改背景颜色基于一个主题/风格
感谢
<?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?
欢呼声,那工作。我会尝试使用类似的方法,但用的LinearLayout,但是这看起来更整洁。 – Glitch