Create a new color drawable

后端 未结 6 770
时光说笑
时光说笑 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 12:57

    By followingthe above advice,to be a summary of this question:

    1. ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#ce9b2c"));`

    2. ColorDrawable colorDrawable = new ColorDrawable(0xFFCE9B2C); Note there is 8 hex digits, not 6 hex digit,which no work. Case all

    3. ColorDrawable colorDrawable = new ColorDrawable(ContextCompat.getColor(mContext,R.color.default_color));

    Selecting up to you!

提交回复
热议问题