Thursday, October 10, 2019

Change EditText border color in Android

Today I will show you a simple How to change EditText border color in Android, to achieve these problems.You should need to perform in layout.xml file in android, you want to change border color edittext in android you just need to do as below:
How to change EditText border color in Android

Step 1: Create layout activity.xml
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    tools:context=".MainActivity"
    android:background="#b6ca9f"
    >
    <EditText
        android:id="@+id/et"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Input your country"
        android:background="@drawable/edittext_bg"
        android:padding="10dp"
        />
</RelativeLayout>
Step 2: Create file edittext_bg.xml in drawable
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@android:color/transparent"/>
            <stroke android:width="1dp" android:color="#a17dff"/>
        </shape>
    </item>
</selector>

No comments:

Post a Comment