How do I set the rounded corner radius of a color drawable using xml?

前端 未结 3 422
南方客
南方客 2020-12-02 07:45

On the android website, there is a section about color drawables. Defining these drawables in xml looks like this:


    

        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 08:38

    mbaird's answer works fine. Just be aware that there seems to be a bug in Android (2.1 at least), that if you set any individual corner's radius to 0, it forces all the corners to 0 (at least that's the case with "dp" units; I didn't try it with any other units).

    I needed a shape where the top corners were rounded and the bottom corners were square. I got achieved this by setting the corners I wanted to be square to a value slightly larger than 0: 0.1dp. This still renders as square corners, but it doesn't force the other corners to be 0 radius.

提交回复
热议问题