【发布时间】:2019-11-25 00:59:21
【问题描述】:
我想在 TextInputLayout 中添加一个微调器,并像这样显示 TextInputEditText 的提示。
我尝试制作自定义 TextInputLayout,但仍然无法为其添加微调器。
我已经添加了这样的带有轮廓视图的 TextInputLayout:-
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:textColorHint="@color/colorGreyView"
android:textSize="20dp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Mobile Number"/>
</com.google.android.material.textfield.TextInputLayout>
【问题讨论】:
-
所以你可以使用水平线性布局作为父级。 Spinner 和文本输入布局都将使用 weight 属性分开。您需要将边框背景应用于该父 linrarlayout。
-
@Piyush 但这不允许提示浮动。应该作为标签出现的提示隐藏起来。这个我已经试过了。
-
@Piyush 两个链接都是针对单个孩子的。两个链接都有助于为微调器添加浮动标签,但没有关于两个嵌套子级的信息。
-
所以你可以使用相对或框架布局来代替线性布局
标签: android android-layout android-textinputlayout