【文件属性】:
文件名称:android实现横屏的代码及思路
文件大小:43KB
文件格式:PDF
更新时间:2021-01-05 01:09:46
AND android id
当屏幕变为横屏的时候,系统会重新呼叫当前Activity的OnCreate方法,你可以把以下方法放在你的OnCreate中来检查当前的方向,然后可以让你的SetContentView来载入不同的Layout xml.
代码如下:if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.i(“info”, “landscape”);
}
else if (this.getResources().getConfiguration().orientatio