Create a new color drawable

后端 未结 6 782
时光说笑
时光说笑 2021-01-30 12:43

I am trying to convert a hex value to an int so I can create a new color drawable. I\'m not sure if this is possible, but according to the documentation, it should. It plainly a

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 13:00

    This is how I converted a Hex color to int and applied to a Background of a View

    Let's say that we have a color #8080000.

    1) Hex to int conversion

    int myColor = Color.parseColor("#808000");
    

    2) Set background

    view.setBackgroundColor(context.getColor(myColor));
    

提交回复
热议问题