android - TextInputLayout 与 OutlinedBox 描边重叠提示

标签 android android-textinputlayout material-components-android

我使用 com.google.android.material:material:1.1.0 并尝试使用带提示的轮廓框制作 EditText。我的问题是框的笔划与提示重叠: enter image description here

这是我的代码:

    <com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:boxStrokeWidth="1dp"
        app:hintEnabled="true">

        <androidx.appcompat.widget.AppCompatAutoCompleteTextView
            android:id="@+id/export_csv_sep_edit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:minWidth="130dp"
            android:layout_gravity="bottom"
            android:digits=",;:.|/*-_"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:imeOptions="actionDone|flagNoFullscreen|flagNoExtractUi"
            android:inputType="text"
            android:maxLength="1"
            android:maxLines="1"
            android:selectAllOnFocus="true"
            android:singleLine="true"
            android:text=","
            android:hint="@string/separator"
            android:textColor="?android:textColorPrimary"
            android:textSize="@dimen/normal_font_size"
            android:completionThreshold="1"/>

    </com.google.android.material.textfield.TextInputLayout>

是素材库有问题,还是我的代码有问题?

最佳答案

这取决于 android:gravity="center" 的使用

<androidx.appcompat.widget.AppCompatAutoCompleteTextView
   android:gravity="center"
   ..>

Starting from 1.2.0-alpha02该错误已修复,并且存在不同的行为。

在任何情况下使用 MaterialAutoCompleteTextViewAutoCompleteTextView 而不是 androidx.appcompat.widget.AppCompatAutoCompleteTextView(MaterialAutoCompleteTextView 使用 AutoCompleteTextView)。

类似于:

<com.google.android.material.textfield.TextInputLayout
    ...
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">

    <AutoCompleteTextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        .....
    />

</com.google.android.material.textfield.TextInputLayout>

关于android - TextInputLayout 与 OutlinedBox 描边重叠提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60722979/

相关文章:

android - 如何去除 Material Button 中图标的色调?

Android Material Date Range Picker - 如何仅更改选定范围日期的文本颜色?

Android 正在将我们的位置列入黑名单

android - PWA 已经支持 GPS 了吗?

android - 如何禁用 FilledTextField 组件?

Android - 如何删除 setError() 的感叹号

android - 在应用程序图标上显示角标(Badge)(数字)的推荐方式是什么?

android - 为 Android 中的交易电子邮件集成 Mailchimp 的 Mandrill

android - TextInput 布局在 API17 的中心显示编辑文本错误图标

android - com.android.support :design:28. 0.0 - 版本 28 是遗留支持库的最后一个版本