Creating a rectangle shape with only two rounded edges

前端 未结 7 710
难免孤独
难免孤独 2021-02-01 03:26

I can create a shape that is a rectangle with all edges rounded. However, what I\'m wanting is a rectangle shape with only 2 of the edges rounded. Is this possible?

I\

7条回答
  •  佛祖请我去吃肉
    2021-02-01 04:04

    I would try drawing a rounded rectangle, and then two additional rectangles of the same size as the rounded rectangle's corner radius, and place them in the corners that you don't want to be rounded.

    So for example, a rounded rectangle with a radius of 15px, and two regular rectangles 15x15px, placed into the corners of the rounded rectangle that should not be rounded.

    EDIT: Re-reading your question, you might be better off making a simple 9-patch image for the top and bottom of your listview. They would stretch to any size that way without pixelization. That would require you to create the images beforehand, though, and doing things with the rectangle shapes would be easier to modify in code later. However, the 9-patch way would be less of a hack.

提交回复
热议问题