Question

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?

Was it helpful?

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>

OTHER TIPS

You can use this thing as it included in API level 1:

editText.setTextColor(getResources().getColor(R.id.your_color));
editText.setBackgroundColor(getResources().getColor(R.id.your_color));

You are setting the background as color white in your style.xml.
In older version it will also set as background color of editttext,dialog like views;
please check this answer.
It is about setting android:windowBackground and android:colorBackground .
Hope it will help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top