2 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
4 int width = getDefaultSize(mVideoWidth, widthMeasureSpec);
5 int height = getDefaultSize(mVideoHeight, heightMeasureSpec);
6 if (mVideoWidth > 0 && mVideoHeight > 0) {
7 if ( mVideoWidth * height > width * mVideoHeight ) {
8 //Log.i("@@@", "image too tall, correcting");
9 height = width * mVideoHeight / mVideoWidth;
10 } else if ( mVideoWidth * height < width * mVideoHeight ) {
11 //Log.i("@@@", "image too wide, correcting");
12 width = height * mVideoWidth / mVideoHeight;
13 } else {
14 //Log.i("@@@", "aspect ratio is correct: " +
15 //width+"/"+height+"="+
16 //mVideoWidth+"/"+mVideoHeight);
17 }
18 }
19 //Log.i("@@@@@@@@@@", "setting size: " + width + 'x' + height);
20 setMeasuredDimension(width, height);
21 }