【发布时间】:2020-01-05 21:19:36
【问题描述】:
我正在使用 Material design library 来制作一个圆形的 editText,我能够做到这一点,但现在我希望它看起来更小一些,我使用了密集的 textField 样式,但我仍然想要视图的高度比那个小。 问题是浮动标签标签,我没有为textField设置提示但是标签标签仍然占用一些空白空间。
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:endIconMode="custom"
app:endIconDrawable="@drawable/ic_speaker_24dp"
app:layout_constraintBottom_toBottomOf="@+id/topBar_view"
app:layout_constraintEnd_toEndOf="@+id/topBar_view"
app:layout_constraintStart_toEndOf="@+id/separater_line"
app:layout_constraintTop_toTopOf="parent"
app:boxCornerRadiusTopStart="20dp"
app:boxCornerRadiusTopEnd="20dp"
app:boxCornerRadiusBottomStart="20dp"
app:boxCornerRadiusBottomEnd="20dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
我只希望 textField 看起来像 chrome url 搜索栏,苗条并且在键入时提示消失,而不是浮动标签。
编辑:我尝试了app:hintEnabled="false" 属性,但仍然有一个空白空间
【问题讨论】:
-
也试试这个 app:hintAnimationEnabled="false"
-
那也没用
-
试试这个应用:在 TextInputLayout 标签内的hintEnabled="false"
标签: android material-design android-textinputlayout material-components material-components-android