onMeasure与 onLayout自定义viewGroup

package com.gy.measureandlayout;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

import java.util.Map;

public class CustomLayout extends ViewGroup {

    public CustomLayout(Context context) {
        super(context);
    }

    public CustomLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        
        int selfWidthSpecModel = MeasureSpec.getMode(widthMeasureSpec);
        int selfHeightSpecModel = MeasureSpec.getMode(heightMeasureSpec);
        int selfWidthSize = MeasureSpec.getSize(widthMeasureSpec);
        int selfHeightSize = MeasureSpec.getSize(heightMeasureSpec);

        for(int i=0;i

你可能感兴趣的:(onMeasure与 onLayout自定义viewGroup)