The citation from View reference:
The size of a view is expressed with a width and a height. A view
actually possess two pairs of width and height values.The first pair is known as measured width and measured height. These
dimensions define how big a view wants to be within its parent (see
Layoutfor more details.) The measured dimensions can be obtained by
callinggetMeasuredWidth()andgetMeasuredHeight().The second pair is simply known as width and height, or sometimes
drawing width and drawing height. These dimensions define the actual
size of the view on screen, at drawing time and after layout. These
values may, but do not have to, be different from the measured width
and height. The width and height can be obtained by callinggetWidth()
andgetHeight().
Well, i can set the measured size in onMeasure(int, int) by setMeasuredDimension(int, int), but how can i set another one, drawing size?
That is set in the
onLayout(boolean, int, int, int, int)method when you determine the left, top, right, bottom dimensions of the layout. When you calllayout(int, int, int, int)orsuper.onLayout(boolean, int, int, int, int), thegetHeight()andgetWidthproperties will be set.