Skip to content Skip to sidebar Skip to footer

Correctly Layout Children With Onlayout In Custom Viewgroup

I am creating a custom ViewGroup. I does need to have 2 FrameLayout one above the other; the one that stays to the bottom must be 20dp, while the other one must cover the rest of t

Solution 1:

The last parameter in the View#layout() method is the bottom of the View. For your bar, you're passing 0, but it should be the height of your custom View, which you can figure from the t and b values passed into onLayout().

bar.layout(0, content.getMeasuredHeight(), bar.getMeasuredWidth(), b - t);

Post a Comment for "Correctly Layout Children With Onlayout In Custom Viewgroup"