Is there any way to create a function that changes the background of an activity?
I need a button that when clicking will change the background of the activity
Is there any way to create a function that changes the background of an activity?
I need a button that when clicking will change the background of the activity
You can change the background of the layout that occupies the entire Activity with the setBackgroundColor () method.
For example:
Your XML:
<FrameLayout
android:id="@+id/root_layout"
android:layout-width="match_parent"
android:layout-height="match_parent">
...
</FrameLayout>
Your Activity:
FrameLayout rootLayout = (FrameLayout) findViewById (R.id.root_layout);
rootLayout.setBackgroundColor(Color.parseColor("#ffffff"));