How to gradient fill a button's background?

后端 未结 2 696
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-15 03:17

I have to create a colored button with gradient fill(starting from the middle of the button along Y axis). If I set the background property of the button to the color I want

2条回答
  •  渐次进展
    2021-01-15 03:47

    How to set background color of a View

    You will need to define a custom StateListDrawable resource, cloned perhaps from the one Android uses for buttons by default, where you change the nine-patch images to be gradients. You might be able to define those gradients in XML, which would mean they would stretch nicely.

提交回复
热议问题