Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom designing EditText

I have custom designed EditText

enter image description here

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:

enter image description here

Any ideas on how to achieve this?

like image 810
Devrath Avatar asked Oct 04 '13 19:10

Devrath


People also ask

What is TextInputLayout?

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.


1 Answers

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

like image 56
Manishika Avatar answered Sep 21 '22 11:09

Manishika