【问题标题】:TextInputLayout & TextInputEditText hintTextInputLayout & TextInputEditText 提示
【发布时间】:2017-04-18 21:46:12
【问题描述】:

这是我的 xml 代码,用于为用户电话号码输入文本 但是当它没有聚焦时,提示标签会以较大的文本大小显示 我的问题是如何使提示标签像密码一样激活,即使字段中没有文本。

<android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColorHint="@color/colorText">

            <android.support.design.widget.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/phone_number"
                android:inputType="number"
                android:maxLines="1"
                android:textColorHint="@color/colorText" />

        </android.support.design.widget.TextInputLayout>

【问题讨论】:

  • 你有没有想过使用编辑文本和文本视图来实现你想要的视图而不是 TextInputLayout?我不认为你需要文本输入布局,好的旧的编辑文本和文本视图就足够了。
  • 我知道我可以做这个解决方案,但我想使用 TextInputEditText。

标签: android android-layout android-support-library


【解决方案1】:

你的提示放错地方了

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/phone_number"
    android:textColorHint="@color/colorText">

    <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:maxLines="1"
        android:textColorHint="@color/colorText" />

</android.support.design.widget.TextInputLayout>

【讨论】:

    猜你喜欢
    • 2018-03-15
    • 1970-01-01
    • 1970-01-01
    • 2016-10-16
    • 2019-02-09
    • 2020-09-28
    • 1970-01-01
    • 2018-10-13
    • 1970-01-01
    相关资源
    最近更新 更多