Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Background for editText in android

enter image description here

<shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
    <solid android:color="#FFFFFF"/>
    <stroke
    android:width="1.5dp"
    android:color="#E53935"
        />

        </shape>

I want to make this type of custom design for editText.

like image 964
dennisrufigill Avatar asked Dec 03 '22 20:12

dennisrufigill


2 Answers

Try this :

enter image description here

Your custom file is perfect just you need to use it in background of edittext

<LinearLayout android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="#ffffff"
        xmlns:android="http://schemas.android.com/apk/res/android">


        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="User name"
            android:padding="15dp"
            android:layout_margin="10dp"
            android:background="@drawable/et_cust"/>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password"
            android:padding="15dp"
            android:layout_marginTop="20dp"
            android:layout_margin="10dp"
            android:background="@drawable/et_cust"/>


    </LinearLayout>

et_cust.xml

 <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid android:color="#FFFFFF"/>

    <stroke
        android:width="2dp"
        android:color="#c9837f"/>

</shape>
like image 135
Vidhi Dave Avatar answered Dec 06 '22 09:12

Vidhi Dave


Use this for EditText as android:background="@drawable/background_et"

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#FFFFFF" /> 

    <stroke android:color="#FF0000"
        android:width="2dp"></stroke>

    <corners android:radius="0dp" />
</shape>

And this for button:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#FF0000" /> 

    <stroke android:color="#FFFFFF"
        android:width="0dp"></stroke>

    <corners android:radius="0dp" />
</shape>
like image 37
Zeero0 Avatar answered Dec 06 '22 10:12

Zeero0