How to get a value of color attribute programmatically

前端 未结 3 2294
自闭症患者
自闭症患者 2021-02-20 05:01

When I use resolveAttribute() to find out a color value of ?attr/colorControlNormal, I got 236:

TypedValue typedValue = ne         


        
3条回答
  •  北海茫月
    2021-02-20 05:27

    It's correct I think, check with it

    HEX

    Integer intColor = -1979711488138;
    String hexColor = "#" + Integer.toHexString(intColor).substring(2);
    

    or

    int color = getCurrentTextColor();
    int a = Color.alpha(color);
    int r = Color.red(color);
    int g = Color.green(color);
    int b = Color.blue(color);
    

提交回复
热议问题