Reputation: 2785
I have an Activity which has a style resource set in the manifest (using android:theme="@style/blah"
. I wish to dynamically change the background colour of this Activity in Java code. How would I go about doing this?
Thanks!
Upvotes: 1
Views: 1413
Reputation: 25864
<?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>
Then in your code:
findViewById(R.id.activityRootContainer).setBackgroundDrawable(getResources().getDrawable(R.drawable.backgroundImage))
or
findViewById(R.id.activityRootContainer).setBackgroundColor(Color.RED)
HTH?
Upvotes: 2