How to create android shape background programmatically?

前端 未结 5 1703
无人共我
无人共我 2020-12-13 03:35

How to create this shape programmatically?




        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 04:14

    I've created a library which can help to create drawables programmatically.

    See here: DrawableToolbox.

    With DrawableToolbox, you can create it by:

    Drawable drawable = new DrawableBuilder()
            .rectangle()
            .solidColor(0xffe67e22)
            .bottomLeftRadius(20) // in pixels
            .bottomRightRadius(20) // in pixels
    //        .cornerRadii(0, 0, 20, 20) // the same as the two lines above
            .build();
    

提交回复
热议问题