【问题标题】:How can set TextInputLayout hintTextAppearance dynamically?如何动态设置 TextInputLayout hintTextAppearance?
【发布时间】:2015-06-13 13:56:20
【问题描述】:

我想动态创建一个新的 TextInputLayout,我必须设置 hintTextAppearance 才能正常工作。

如何动态设置hintTextAppearance?

【问题讨论】:

标签: android android-design-library


【解决方案1】:

hintTextAppearance 将与您设置 EditText 的 Text Appearance 相同。

【讨论】:

  • editText.setHint 不能解决我的问题。当我添加 TextInputLayout 时,会出现以下错误:原因:java.lang.UnsupportedOperationException:无法转换为颜色:android.content.res.TypedArray.getColor(TypedArray.java:326) 处的 type=0x2。 support.design.widget.CollapsingTextHelper.setCollapsedTextAppearance(CollapsingTextHelper.java:166) 设置 hintTextAppearance 解决我的问题。
【解决方案2】:
        TextInputLayout textInput = findViewById(text input id);
        textInput.setHintTextAppearance(R.style.FloatingHintTextStyle);

       <style name="FloatingHintTextStyle" parent="TextAppearance.Design.Hint">
          <item name="android:textColor">@color/floating_hint_color</item>
       </style>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-09
    • 2017-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多