Reputation: 500
I tried this:
rounded_textfield.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#EEEEEE"/>
<corners
android:bottomRightRadius="8dp"
android:bottomLeftRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp"/>
</shape>
activity.xml:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/searchField" android:layout_row="0" android:layout_column="0"
android:drawableLeft="@drawable/search"
android:background="@drawable/rounded_edittext" android:minHeight="50dp"/>
In the editor it's grey, but on the phone it's white.
Upvotes: 3
Views: 202
Reputation: 2770
Your code is right, just clean the project. One thing you should remember that the different colors look different in different devices according to their display settings and their display screens.
Upvotes: 4
Reputation: 88
Create a file named custom_edit_text.xml and put it in xml folder in your res folder of your project.
Paste the following code there:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke android:width="1dip" android:color="#ffffff"/>
</shape>
Now just refer to this xml in your activty_main.xml file like this:
<EditText
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_centerHorizontal="true
android:background="@xml/custom_edit_text">
</EditText>
For custom colors visit [this][1] link.
Cheers!
Upvotes: 0
Reputation: 1924
Try this,
<EditText
android:id="@+id/edtPassword"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="@drawable/rounded_corner"
android:ems="10"
android:hint="Enter Password"
android:inputType="textPassword"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:singleLine="true"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
android:textSize="16sp" />
rounded_corner.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@android:color/transparent" />
<corners
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
<stroke
android:width="1dp"
android:color="@android:color/white" />
<padding
android:bottom="1dip" />
</shape>
Upvotes: 1