Tuesday, July 30, 2019

Change EditText bottom border color Android

Hello everyone today I will introduce you to Change Android EditText bottom border color , the following are issues and questions from many ... thumbnail 1 summary
Hello everyone today I will introduce you to Change Android EditText bottom border color, the following are issues and questions from many people encounter.
I am creating an EditText in my layout xml file, But I want to change color line in EditText from Holo to (for example) red. How that can be done?
Change EditText bottom border color Android

you can change the following code change EditText boder color.
Step 1. Create layout activity-layout.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="#c9cac1"
    >
    <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 res/drawable/edittext_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
              <stroke
                android:color="#ff1e0c"
                android:width="2dp"
                />
        </shape>
    </item>
       <item
        android:bottom="2dp"
        >
        <shape android:shape="rectangle">
            <solid android:color="#fffbce"/>
        </shape>
    </item>
</layer-list>
The following are the results of the program change EditText botom bodercolor Android.
Change EditText bottom border color Android


No comments

Post a Comment