Correctly scale the surface with 4:3 aspect ratios. Merged from 6f70's PR.

This commit is contained in:
Cameron Gutman
2015-02-01 03:22:28 -05:00
parent 5e45aeb70b
commit fdbecfa6dd

View File

@@ -222,12 +222,22 @@ public class Game extends Activity implements SurfaceHolder.Callback,
{
// Get the visible width of the activity
double visibleWidth = getWindow().getDecorView().getWidth();
double visibleHeight = getWindow().getDecorView().getHeight();
ViewGroup.LayoutParams lp = sv.getLayoutParams();
double vidRatio = vidHeight / vidWidth;
double visibleRatio = visibleHeight / visibleWidth;
// Calculate the new size of the SurfaceView
if (vidRatio < visibleRatio) {
lp.width = (int) visibleWidth;
lp.height = (int) ((vidHeight / vidWidth) * visibleWidth);
}
else {
lp.width = (int) ((vidWidth / vidHeight) * visibleHeight);
lp.height = (int) visibleHeight;
}
// Apply the size change
sv.setLayoutParams(lp);