Android: Custom View
I am trying to make a custom view that is square, using the width as the height. I am also using a pre-defined layout which I inflate as it's UI. As soon as I overrode onMeasure, the custom view no longer appears. Here is my code:

    public class myView extends RelativeLayout{

	public myView(Context context) {
		super(context);
		addView(setupLayout(context));
	}
	
	
	public MenuButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		addView(setupLayout(context));
	}


	public myView(Context context, AttributeSet attrs) {
		super(context, attrs);
		addView(setupLayout(context));
	}

	private View setupLayout(Context context) {
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View myView = inflater.inflate(R.layout.view_layout, null);
		return myView;
	}

	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(widthMeasureSpec));
	}
	
     }

I have 2 questions:

1. How do I override onMeasure so that it draws my view the way I am expecting it to?
2. Is there any way I can make this more efficient in terms of the view hierarchy (i.e. not be putting a RelativeLayout inside a RelativeLayout)

Android: Custom View
===

I am trying to make a custom view that is square, using the width as the height. I am also using a pre-defined layout which I inflate as it's UI. As soon as I overrode onMeasure, the custom view no longer appears. Here is my code:

    public class myView extends RelativeLayout{

	public myView(Context context) {
		super(context);
		addView(setupLayout(context));
	}
	
	
	public MenuButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		addView(setupLayout(context));
	}


	public myView(Context context, AttributeSet attrs) {
		super(context, attrs);
		addView(setupLayout(context));
	}

	private View setupLayout(Context context) {
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View myView = inflater.inflate(R.layout.view_layout, null);
		return myView;
	}

	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(widthMeasureSpec));
	}
	
     }

I have 2 questions:

1. How do I override onMeasure so that it draws my view the way I am expecting it to?
2. Is there any way I can make this more efficient in terms of the view hierarchy (i.e. not be putting a RelativeLayout inside a RelativeLayout)
