您的位置:首页 > 其它

屏幕的适配

2015-11-09 16:29 225 查看
Display currentDisplay;

currentDisplay = getWindowManager().getDefaultDisplay();

if (videoWidth > currentDisplay.getWidth()

|| videoHeight > currentDisplay.getHeight()) {

float heightRatio = (float) videoHeight

/ (float) currentDisplay.getHeight();

float widthRatio = (float) videoWidth

/ (float) currentDisplay.getWidth();

if (heightRatio > 1 || widthRatio > 1) {

if (heightRatio > widthRatio) {

videoHeight = (int) Math.ceil((float) videoHeight

/ (float) heightRatio);

videoWidth = (int) Math.ceil((float) videoWidth

/ (float) heightRatio);

} else {

videoHeight = (int) Math.ceil((float) videoHeight

/ (float) widthRatio);

videoWidth = (int) Math.ceil((float) videoWidth

/ (float) widthRatio);

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: