Search code examples
androidandroid-edittextplatform

change edittext text color in older platform version


I am using a dark background for my app. The text color of edittext is set as white. It is working fine in latest versions. But in older versions since the edittext itself is displaying as white color i am not able to see the entered text in edittext. how can i handle this?


Solution

  • Make new xml file in res/drawable name it rounded_edit_text then paste this:

    <?xml version="1.0" encoding="utf-8"?>
    <shape  xmlns:android="http://schemas.android.com/apk/res/android" 
        android:shape="rectangle" android:padding="10dp">
        <solid android:color="#F9966B" />
        <corners
            android:bottomRightRadius="15dp"
            android:bottomLeftRadius="15dp"
            android:topLeftRadius="15dp"
            android:topRightRadius="15dp" />
    </shape>
    

    In res/layout copy and past following code (code of EditText) :

    <EditText
        android:id="@+id/txtdoctor"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/rounded_edit_text"
        android:ems="10" >
        <requestFocus />
    </EditText>