TextInputLayout 与 OutlinedBox 描边重叠提示
TextInputLayout with OutlinedBox stroke overlaps the hint
我使用 com.google.android.material:material:1.1.0
并尝试使用带提示的轮廓框制作 EditText。我的问题是框的笔划与提示重叠:
这是我的代码:
<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>
是素材库的bug,还是我的代码有问题?
1.1.0
版本好像有不少bug
目前他们已经在最新版本中解决了一些问题,请将您的版本更新到最新版本 (see latest releases here)
目前最新版本是:1.2.0-alpha06
或在您的应用中使用以下内容 gradle :
implementation 'com.google.android.material:material:1.2.0-alpha06
Refer here 用于针对 material 个组件报告的问题,或者您可以自己提出一个问题
这取决于android:gravity="center"
的使用
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:gravity="center"
..>
错误已修复,并且存在不同的行为。
在任何情况下都使用 MaterialAutoCompleteTextView
或 AutoCompleteTextView
而不是 androidx.appcompat.widget.AppCompatAutoCompleteTextView
(有一个 MaterialAutoCompleteTextView
的自动 inflation 使用 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>
我使用 com.google.android.material:material:1.1.0
并尝试使用带提示的轮廓框制作 EditText。我的问题是框的笔划与提示重叠:
这是我的代码:
<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>
是素材库的bug,还是我的代码有问题?
1.1.0
目前他们已经在最新版本中解决了一些问题,请将您的版本更新到最新版本 (see latest releases here)
目前最新版本是:1.2.0-alpha06
或在您的应用中使用以下内容 gradle :
implementation 'com.google.android.material:material:1.2.0-alpha06
Refer here 用于针对 material 个组件报告的问题,或者您可以自己提出一个问题
这取决于android:gravity="center"
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:gravity="center"
..>
在任何情况下都使用 MaterialAutoCompleteTextView
或 AutoCompleteTextView
而不是 androidx.appcompat.widget.AppCompatAutoCompleteTextView
(有一个 MaterialAutoCompleteTextView
的自动 inflation 使用 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>