屏幕的适配
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);
}
}
}
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);
}
}
}
相关文章推荐
- 复选框的全选、取消
- Lightoj 题目1067 Combinations(lucas)
- 翻转英文句子中单词的顺序
- 第十一周项目1-二叉树算法验证(二叉树算法构造的验证)
- 线性拟合和线性回归
- Redis学习笔记之(十一)管道与节省空间
- 第九周项目四-广义表算法库
- 第十周 项目3--利用二叉树遍历思想解决问题
- MYSQL 5.0 以上 8小时超时问题
- 自定义UITableViewCell(registerNib: 与 registerClass: 的区别)
- 第十一周项目1层次遍历算法的验证
- 第7周项目6--停车场模拟
- window下安装MPI
- linux 下VLAN功能实现(转)
- 用可重用的链表模块来实现命令行菜单小程序V2.5
- 攻略强制换行与强制不换行
- CSS设计模式之三权分立模式篇
- CANVAS左开右闭
- CSS3中的Opacity多浏览器透明度兼容性问题
- log4j