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

Asked

Viewed 107 times

0

Is there any way to create a function that changes the background of an Activity?

I need a button that will change the Activity background

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>

His Activity:

FrameLayout rootLayout = (FrameLayout) findViewById (R.id.root_layout);
rootLayout.setBackgroundColor(Color.parseColor("#ffffff"));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.