我搜索并尝试了很多解决方案,但还是不行。
(仍然显示“FilledBox”样式)
我的代码有什么问题?
input_layout.xml
<com.google.android.material.textfield.TextInputLayout
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"
android:id="@+id/text_input_layout"
tyle="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
...
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_input_edit_text"
...
/>
</com.google.android.material.textfield.TextInputLayout>
styles.xml
<style name="AppBaseTheme" parent="android:Theme.MaterialComponents.Light"/>
<style name="AppTheme" parent="AppBaseTheme">
<item name="textInputStyle">@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox</item>
</style>
你可以尝试这个代码,它对我有用
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxStrokeColor="@color/bg_blue_tint"
app:boxStrokeWidth="2dp"
app:boxStrokeWidthFocused="2dp"
app:endIconDrawable="@drawable/ic_email"
app:endIconMode="custom"
app:hintEnabled="false"
android:hint="Email"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/email"
android:maxLines="1"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:textColorHint="@color/hint_color" />
</com.google.android.material.textfield.TextInputLayout>