Android get color as string value

前端 未结 11 1481
青春惊慌失措
青春惊慌失措 2021-01-30 19:28

If i defined a color in resources


    #123456

it\'s possible

11条回答
  •  一生所求
    2021-01-30 19:41

    This is how I've done it:

    String color = "#" + Integer.toHexString(ContextCompat.getColor
    (getApplicationContext(), R.color.yourColor) & 0x00ffffff);
    

提交回复
热议问题