Android Drawable: Specifying shape width in percent in the XML file?

前端 未结 5 1507
攒了一身酷
攒了一身酷 2020-12-06 04:06

I\'m trying to create a simple Drawable that I want to set as the background for a view (using setBackgroundDrawable). I simply want to divide the background of the

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 04:38

    there is no true percentage setting, but you might get close.

    it seems like the easiest way to achieve this is to use an image as your background drawable and just do a black and white split image.

    the only other way I know to split anything is to use 2 views, each with its own bg color, and each given the same positive value for android:layout_weight attribute (ie. 50/50). they will then split the available space.

    hope this helps!

提交回复
热议问题