Im has two custom viewgroups
, superViewGroup
and subViewGroup
. The subview group contains views. I am adding my supervisual group to linearLayout and subViewGroups
to my superViewGroup
.
The onMeasure()
supervisor group receives the call, but not in the subview subgroup. but in both cases the onLayout()
method gets called.
Code as follows
public class SuperViewGroup extends ViewGroup{ public SuperViewGroup(Context context) { super(context); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); Log.i("boxchart","INSIDE ON MEASURE SUPER VIEWGROUP"); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int count = getChildCount(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() != View.GONE) { child.layout(0, 0, getWidth(), getHeight()); } } } } public class SubViewGroup extends ViewGroup{ public SubViewGroup(Context context) { super(context); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); Log.i("boxchart","INSIDE ON MEASURE SUB VIEWGROUP"); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int count = getChildCount(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() != View.GONE) { child.layout(0, 0, getWidth(), getHeight()); } } } }
Comments are appreciated. thanks in advance.
source share