I\'m trying to show a MyCustomLinearLayout
which extends LinearLayout
. I\'m inflating the MyCustomLinearLayout
with the android:layo
That's not how you override the onMeasure
method especially of a default SDK layout. Right now with your code you just made the MyCustomLinearLayout
square assigning it a certain value. But, you didn't measured its children so they are sizeless and don't appear on the screen.
I'm not sure this would work but try this:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int size = getMeasuredHeight();
super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY));
}
Of course this will basically do the work of onMeasure
twice but the ImageView
should be now visible filling it's parent. There are other solutions but your question is a bit scarce on details.