Java tutorial
//package com.java2s; import android.app.Activity; import android.util.DisplayMetrics; public class Main { private static final int VIDEO_WIDTH_RATIOS = 16; private static final int VIDEO_HEIGHT_RATIOS = 9; public static int getVideoHeight(Activity activity) { return Math.min(getScreenWidth(activity) * VIDEO_HEIGHT_RATIOS / VIDEO_WIDTH_RATIOS, getScreenHeight(activity)); } public static int getScreenWidth(Activity activity) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); return displaymetrics.widthPixels; } public static int getScreenHeight(Activity activity) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); return displaymetrics.heightPixels; } }