【问题标题】:is it possible use html tag or spannable in TextInputLayout hint?是否可以在 TextInputLayout 提示中使用 html 标签或 spannable?
【发布时间】:2017-09-26 06:08:18
【问题描述】:

我的布局中有一个 TextInputLayout,我想在它的提示中使用 html 标签或 spannable,但它不适用于它。

我在 google 中搜索了所有链接,但结果是“现在不可能,也许在下一个版本中并且可以更新”。

是否可以自定义 TextInputLayout 视图以在提示中接受 html 标记?我该怎么做?

【问题讨论】:

  • 添加一些代码是个好主意。
  • @iMDroid 感谢您的帮助
  • @iMDroid 你去年问了一个像我这样的问题。你找到解决办法了吗?
  • 我的意思是在这里发布一些代码来帮助人们理解你的问题。

标签: android html hint textinputlayout


【解决方案1】:

在 TextInputLayout 的布局 xml 文件中添加以下代码:

<android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/activity_horizontal_margin"
        app:hintAnimationEnabled="false">

        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
              android:hint="@string/enter_message" />

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

在 string.xml 文件中添加以下代码:

<string name="enter_message">Enter Message<font fgcolor="red">*</font></string>

【讨论】:

  • 您不能使用 XML 设置 HTML 数据。必须在代码中完成,否则数据不生效
  • @hamed 你能添加相同的代码吗..这将有助于理解....
猜你喜欢
  • 1970-01-01
  • 2010-12-27
  • 1970-01-01
  • 2021-12-11
  • 1970-01-01
  • 2012-04-07
  • 2022-12-13
  • 1970-01-01
  • 2018-06-14
相关资源
最近更新 更多