I have custom designed EditText
search_page.xml
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="10dp" android:background="#E1E1E1" android:weightSum="1" > <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight=".25" android:text="City" /> <EditText android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/rounded_edittext" android:layout_weight=".75" /> </LinearLayout>
rounded_edittext.xml
<?xml version="1.0" encoding="utf-8"?> <!-- res/drawable/rounded_edittext.xml --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:padding="10dp" android:shape="rectangle" > <solid android:color="#FFFFFF" /> <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" /> </shape>
I want to use color code #2f6699
to get a border color like an outline to the EditText
text box as below:
Any ideas on how to achieve this?
TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.
Use the below code in your rounded_edittext.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#FFFFFF" /> <stroke android:width="1dp" android:color="#2f6699" /> <corners android:radius="10dp" /> </shape>
This should work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With