Reputation: 280
I want to create an attractive UI. I want to create a rectangular box around the edittext. How can I make it?
Upvotes: 2
Views: 2978
Reputation: 364694
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"
Upvotes: 2
Reputation: 66
create a drawable with shape rectangle and apply background to edit text
<shape android:shape="rectangle">
<stroke android:width="1dip" android:color="#4e555f" />
</shape>
<EditText
android:id="@+id/sign_in_mobile_no"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="drawable name"/>
Upvotes: 1