How to change shape colors in Drawable?

后端 未结 3 1970
猫巷女王i
猫巷女王i 2021-02-09 17:29

I have the following button:

相关标签:
3条回答
  • 2021-02-09 18:10

    You could try using a ColorStateList, it serves the purpose you are after, I think.

    0 讨论(0)
  • 2021-02-09 18:26

    It is possible by having different images in drawable. Consider, if you want to change the green color into black, you need to have black color circle in drawable and then try this code. This will help you..

    On the button click event, use this code

    public void onClick(View v) {
       if(v == ButtonName) {
         ButtonName.setImageResource(R.drawable.ImageName);
       }
    }
    
    0 讨论(0)
  • 2021-02-09 18:27

    Late reply, but I figured out that you can access each layer in a LayerList using FindDrawableByLayerId(). Then I have access to each object and set the appropriate color!

    0 讨论(0)
提交回复
热议问题