onMeasure не вызывается в моей пользовательской группе просмотра android

Im есть две пользовательские группы просмотра , superViewGroup и subViewGroup . Подгруппа просмотра содержит представления. Я добавляю свою группу superviewgroup в linearLayout, а subViewGroups - в мою группу superview .

Группа суперпредставлений onMeasure () вызывается, но не входит в подгруппу. но в обоих случаях вызывается метод onLayout () .

Следующий код

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());

            }
        }


    }


}

Комментарии приветствуются. заранее спасибо.

6
задан Natali 1 March 2012 в 21:01
поделиться