Android 屏幕旋转的处理
来源:互联网 发布:m1005找不到扫描软件 编辑:程序博客网 时间:2024/05/17 04:52
1
2
android:screenOrientation=
"landscape"
//横屏
android:screenOrientation=
"portrait"
//竖屏
1
2
// activity的 onCreate 函数中
this
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
1
android:configChanges=
"orientation|screenSize"
1
2
3
4
@Override
public
void onConfigurationChanged(Configuration newConfig) {
super
.onConfigurationChanged(newConfig);
}
1
2
3
4
5
6
7
8
9
public
class
MyOrientationDetector
extends
OrientationEventListener{
public
MyOrientationDetector( Context context ) {
super
(context );
}
@Override
public
void
onOrientationChanged(
int
orientation) {
Log.i(
"MyOrientationDetector "
,
"onOrientationChanged:"
+orientation);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if
(orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
return
;
//手机平放时,检测不到有效的角度
}
//只检测是否有四个角度的改变
if
( orientation >
350
|| orientation<
10
) {
//0度
orientation =
0
;
}
else
if
( orientation >
80
&&orientation <
100
) {
//90度
orientation=
90
;
}
else
if
( orientation >
170
&&orientation <
190
) {
//180度
orientation=
180
;
}
else
if
( orientation >
260
&&orientation <
280
) {
//270度
orientation=
270
;
}
else
{
return
;
}
Log.i(
"MyOrientationDetector "
,
"onOrientationChanged:"
+orientation);
0 0
- Android 屏幕旋转的处理
- Android开发实践:屏幕旋转的处理
- Android开发实践:屏幕旋转的处理
- Android开发实践:屏幕旋转的处理
- Android开发实践:屏幕旋转的处理
- Android开发实践:屏幕旋转的处理
- 屏幕旋转角度的处理
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
- iOS-最新,最全的App上架教程
- RMI原理抄袭
- IBM专家亲自解读 Spark2.0 操作指南
- nodejs学习之表单提交
- 【一天一道LeetCode】#155. Min Stack
- Android 屏幕旋转的处理
- CUICatalog: Invalid asset name supplied:
- Sempahore
- 杂谈
- iOS app 性能优化
- Spring自动装配
- 通信原理中的几个重要概念
- sybase jdbc 创建临时表
- Layer2-多层交换原理