Nom*_*sta 3 android material-components material-components-android
当TextInputLayout处于聚焦模式时,有没有办法删除浮动标签(提示)?
当我尝试在app:hintEnabled="false"inside 中设置和提示时TextInputeEditText,TextInputLayout通过隐藏顶部笔画表现得很奇怪。
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Text">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
重要的是我在版本中使用材料组件 1.1.0-alpha01.
编辑
这是它的样子(当输入未聚焦时):
顶部行程被切断。
是的,有一种相当简单的方法可以删除浮动标签提示,并且只在TextInputLayout.
这可以通过禁用 中的提示TextInputLayout并在 上设置提示来轻松实现,TextInputEditText而不是像TextInputLayout这样:
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint text comes here" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我在 Material Components v1.2.0 中尝试过这个
尝试将文本布局和编辑文本的提示设置为空:-
<com.google.android.material.textfield.TextInputLayout
app:boxBackgroundMode="outline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:hint=""
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
如果您想使用提示,那么您可以使用自定义可绘制对象作为 EditText 的背景:-
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp"/>
<solid android:color="#ffffff"/>
<stroke android:color="#000000"
android:width="2dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3461 次 |
| 最近记录: |