Is there a function that changes the background of an activity in android studio?

0

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

    
asked by anonymous 30.05.2017 / 23:04

1 answer

0

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"));
    
31.05.2017 / 04:29