You have to add the style style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
to TextInputLayout
If you have moved away from the android support library and are currently using Material Design Components .
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/emailTextInputLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/edit_text_horizontal_margin"
android:layout_marginEnd="@dimen/edit_text_horizontal_margin"
android:layout_marginBottom="@dimen/edit_text_vertical_margin"
android:hint="Username"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/emailTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
If not, I suggest you to read the article I have written on how to migrate to Material Design Components .
Old Answer:
Eg:
<android.support.design.widget.TextInputLayout
android:id="@+id/emailTextInputLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/edit_text_horizontal_margin"
android:layout_marginEnd="@dimen/edit_text_horizontal_margin"
android:layout_marginBottom="@dimen/edit_text_vertical_margin"
android:hint="Username"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.design.widget.TextInputEditText
android:id="@+id/emailTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
支持新库
implementation 'com.google.android.material:material:1.1.0'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.