In my application I am using EditText. As we know that in new versions EditText does not have a border and it just displays a bottom line.
Now I want to set the height/thickness of the bottom line as 1dp.
In my application I am using EditText. As we know that in new versions EditText does not have a border and it just displays a bottom line.
Now I want to set the height/thickness of the bottom line as 1dp.
Just use the standard TextInputLayout
with a Filled Box style: Widget.MaterialComponents.TextInputLayout.FilledBox
.
Something like:
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
...>
<com.google.android.material.textfield.TextInputEditText
.../>
</com.google.android.material.textfield.TextInputLayout>
It is the result:
The default value of the underline stroke in a filled box when it is not focused is 1dp.
If you would like to customize the width you can use these attribute in the layout:
app:boxStrokeWidth="xxdp"
app:boxStrokeWidthFocused="xxdp"
or in a custom style:
<item name="boxStrokeWidth">xxdp</item>
<item name="boxStrokeWidthFocused">xxdp</item>
Note: it requires the version 1.1.0
.
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/r..."
android:thickness="3dp"
android:shape="rectangle">
<stroke android:width="3dp" android:color="#4799E8"/>
</shape>
add this in drawable resource file and in edit text change its background:
<EditText
android:background="@drawable/drawableResourceFileName"/>