Step 1: Learn How to Add Color Resources
In the Project panel, double-click on colors.xml (res > values > color.xml) to open the color resource file.
Currently there are three colors that have been defined.
** Different Versions of Android Studio use different colors.
2. Go to fragment_first.xml (Android > app > res > layout > fragment_first.xml) and go to Code view.
3. Add android:fillViewport="true"
somewhere in the code underneath <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
4. Switch to Design view. Click on the existing TextView and delete it and add a new TextView anywhere underneath button the button.
5. Add a new property anywhere in the TextView code called android:background and begin to set its value to @color.
6. Select @color/design_default_color_primary_dark
android:background="@color/design_default_color_primary_dark"
7. Create a new property, android:textColor, and make it equal to @android:color/white
android:textColor="@android:color/white"
Step 2: Change Screen Background Color
In colors.xml, create a new color resources with the name screenBackground with a color value #FFEE58
<color name="screenBackground">#FFEE58</color>
2. Return to fragment_first.xml
3. Select ConstraintLayout from the Component Tree (Go to design view and it should be in the bottom left)
4. Select Background from the Attributes panel (Located on the right side of the screen) and press Enter. Type "c" in the field that appears.
5. Select @color/screenBackground from the menu of colors and press Enter.
6. Click on the yellow patch (it might be look like a pencil) in the background field. It shows a list of colors defined in colors.xml. Click the Custom tab to choose a custom color. Select any color that you want.
Your design view should look something like this (The colors might vary) :