The rounded corners method of EditText is implemented in Android

  • 2020-05-09 19:20:13
  • OfStack

1. Add the xml file rounded_editview.xml under drawable


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#FFFFFF"></solid>
    <padding android:left="10dp"
        android:top="10dp"
        android:right="10dp"
        android:bottom="10dp"></padding>
    <corners android:radius="15dp"></corners>
</shape>

2. Reference this xml in the background property of EditText


<EditText 
        android:id="@+id/et_username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:background="@drawable/rounded_editview"
        android:hint="@string/text_hint_username"/>


Related articles: