I'd like to create a rectangle shape with two solid colors (horizontally) to achieve something like this:
I heard about layer-list
, i though i could use it to contains two rectangle with a different color but it seems that it only lays shapes vertically.
Is there a way to achieve this using lalyer-list or should i use something totally different? I'd like to keep it simple with ability to change the shape colors at runtime.
Thanks.
You can create custom drawable for this. Just extend Drawable class.
Here is a sample code which draws a rectangle like you wanted, you can provide any number of colors.
this will surely draw the shape as per your Requirement :
Adjust size of
<item>
as you need !This will give you two colors half and half vertically. Put this code in a
drawable
resource.