T_Bacon
T_Bacon

Reputation: 404

Android Textview background takes on layout background colour

I have set the background of a RelativeLayout to the colour black. Unfortunately, all the EditText's within my layout have now also turned black (so that I can't see the text as the text is black). Obviously I could change the text colour, but that's not what I want. I can't work out how to get the EditText's back to the default style.

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:gravity="top"
    android:background="@color/BLACK" >

    <TextView
        android:id="@+id/textAddRecTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dp"
        android:text="@string/title_add_rec_layout"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/WHITE" />

    <EditText
        android:id="@+id/editFirstName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textAddRecTitle"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:ems="14"
        android:hint="@string/first_name"
        android:inputType="textPersonName" />

    <EditText
        android:id="@+id/editLastName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/editFirstName"
        android:layout_marginTop="25dp"
        android:ems="14"
        android:hint="@string/last_name"
        android:inputType="textPersonName" />

    <EditText
        android:id="@+id/editEmail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/editLastName"
        android:layout_marginTop="25dp"
        android:ems="14"
        android:hint="@string/email"
        android:inputType="textEmailAddress" />

    <EditText
        android:id="@+id/editPhoneNumber"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/editEmail"
        android:layout_marginTop="25dp"
        android:ems="14"
        android:hint="@string/phone_num"
        android:inputType="phone" />

    <EditText
        android:id="@+id/editAddress1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editPhoneNumber"
        android:layout_below="@+id/editPhoneNumber"
        android:layout_marginTop="25dp"
        android:ems="14"
        android:hint="@string/address1" />

    <EditText
        android:id="@+id/editTown"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editAddress2"
        android:layout_below="@+id/editAddress2"
        android:layout_marginTop="25dp"
        android:ems="14"
        android:hint="@string/town" />

    <EditText
        android:id="@+id/editAddress2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editAddress1"
        android:layout_below="@+id/editAddress1"
        android:layout_marginTop="25dp"
        android:ems="14"
        android:hint="@string/address2" />

    <EditText
        android:id="@+id/editCounty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editTown"
        android:layout_below="@+id/editTown"
        android:layout_marginTop="25dp"
        android:ems="14"
        android:hint="@string/county" />

    <EditText
        android:id="@+id/editPostCode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editCounty"
        android:layout_below="@+id/editCounty"
        android:layout_marginTop="25dp"
        android:ems="14"
        android:hint="@string/postcode" />

    <Button
        android:id="@+id/btnSaveCustomerInfo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:text="@string/btn_savecustomerinfo" />

</RelativeLayout>

Upvotes: 0

Views: 1387

Answers (1)

TootsieRockNRoll
TootsieRockNRoll

Reputation: 3288

change the background of the EditText to android:background="@color/WHITE" (or whatever color for that matter)

here is a tip

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listview_background_shape" >

    <corners
        android:bottomLeftRadius="4dp"
        android:bottomRightRadius="4dp"
        android:topLeftRadius="4dp"
        android:topRightRadius="4dp" />

    <solid android:color="#ffffff" />

    <stroke android:width="1dp"
        android:color="#c3c3c3"/>

</shape>

name this file background_et.xml and put it in your drawable folder

then for your edittext

android:background="@drawable/background_et"

this will change your edittext according to those values in the file, all you have to do is play with those values until you get what you want

Upvotes: 2

Related Questions