When i change the background color of editText, the whole background color changes in android studio

Viewed 1247

I am having isssue in changing the background color of the password in android studio and the issue is when i change the background color of the password field, the whole background color of the screen chages. Before applying background color:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#201953"
    >

    <TextView
        android:text="Trip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView1"
        android:textSize="80sp"
        android:textStyle="bold"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="80dp"
        android:textColor="@color/colorWhite"/>

    <TextView
        android:text="mat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView2"
        android:textSize="50sp"
        android:textStyle="bold"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="-10dp"
        android:layout_marginLeft="30dp"
        android:textColor="@color/colorWhite"/>
    <EditText
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:ems="10"
        android:id="@+id/editText4"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:hint="Password"
        android:gravity="center"
        android:textColor="@color/colorBlack"
        android:layout_gravity="center"
         />
</LinearLayout>

Before adding background color to password field layout is below:

Before adding background color to password field

After applying background color to password field:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#201953"
    >

    <TextView
        android:text="Trip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView1"
        android:textSize="80sp"
        android:textStyle="bold"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="80dp"
        android:textColor="@color/colorWhite"/>

    <TextView
        android:text="mat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView2"
        android:textSize="50sp"
        android:textStyle="bold"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="-10dp"
        android:layout_marginLeft="30dp"
        android:textColor="@color/colorWhite"/>
    <EditText
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:ems="10"
        android:id="@+id/editText4"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:hint="Password"
        android:gravity="center"
        android:textColor="#ffffff"
        android:layout_gravity="center"
        android:background="#fff"
         />
</LinearLayout>

After adding background color to the password field layout is below:

After adding background color to the password field

3 Answers
Related