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
The way I found to do this was by creating my own class inheriting from RelativeLayout, where I override the onMeasure method. At this stage, the height of the view is known, so I fetched the background, and manually set the inset of the items using setLayerInset.
LayerDrawable bg = (LayerDrawable)getBackground();
int h = getMeasuredHeight();
bg.setLayerInset(1, 0, 0, 0, h/2);
This method is a bit cumbersome though. In most cases, the answer provided by chris should be sufficient.