I want to create an attractive UI. I want to create a rectangular box around the edittext. How can I make it?
Just use the standard TextInputLayout
with an OutlinedBox style:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TEXT"/>
</com.google.android.material.textfield.TextInputLayout>
You can use the boxStrokeWidth
and boxStrokeColor
to change width and color.
<com.google.android.material.textfield.TextInputLayout
app:boxStrokeColor="@color/xxxx"
app:boxStrokeWidth="2dp"