How to use RippleDrawable programmatically in code (not xml) with Android 5.0 Lollipop?

前端 未结 3 460
我在风中等你
我在风中等你 2020-12-13 04:32

I have the following code for my ripple:




        
3条回答
  •  忘掉有多难
    2020-12-13 04:40

    Basically, you need to create a new RippleDrawable object. For pre-Lollipop devices, you want a StateListDrawable (as others already suggested). I've written a somewhat resourceful GIST with a bunch of useful methods related to Drawables and coloring: https://gist.github.com/milosmns/6566ca9e3b756d922aa5

    Most likely you will want to use #getBackgroundDrawable() from that singleton.

提交回复
热议问题