How to change the floating label color of TextInputLayout

前端 未结 25 1995
[愿得一人]
[愿得一人] 2020-11-22 15:03

With reference to the new TextInputLayout released by Google, how do I change the floating label text color?

Setting colorControlNormal,

25条回答
  •  醉梦人生
    2020-11-22 15:46

    Ok, so, I found this answer very helpful and thanks to all the people who contributed. Just to add something, though. The accepted answer is indeed the correct answer...BUT...in my case, I was looking to implement the error message below the EditText widget with app:errorEnabled="true" and this single line made my life difficult. it seems that this overrides the theme I chose for android.support.design.widget.TextInputLayout, which has a different text color defined by android:textColorPrimary.

    In the end I took to applying a text color directly to the EditText widget. My code looks something like this:

    styles.xml

    @color/my_yellow
    @color/my_yellow_dark
    @color/my_yellow_dark
    @android:color/white
    @color/dark_gray
    @color/light_gray
    true
    false
    @color/dark_gray
    @android:color/black
    @android:color/white
    

    And my widget:

    
    
            
    
    

    Now it displays black text color instead of the textColorPrimary white.

提交回复
热议问题