How to change the floating label color of TextInputLayout

前端 未结 25 2125
[愿得一人]
[愿得一人] 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条回答
  •  猫巷女王i
    2020-11-22 15:21

    Try The Below Code It Works In Normal State

     
    
         
    
     
    

    In Styles Folder TextLabel Code

     
    

    Set To Main Theme of App,It Works Only Highlight State Only

     @color/Color Name
    

    Update:

    UnsupportedOperationException: Can't convert to color: type=0x2 in api 16 or below

    Solution

    Update:

    Are you using Material Components Library

    You can add below lines to your main theme

     @color/your_color // Activated State
     @color/your_color // Normal State
    

    or else do you want different colors in noraml state and activated state and with customization follow below code

    
    
    
    
    
    
    
    
    
    

    Add the below line to your main theme or else you can set style to textinputlayout in your xml

    @style/Widget.App.TextInputLayout
    

提交回复
热议问题