Android 4.1-4.2 默认窗体旋转180 度代码
2015-06-22 23:56
471 查看
1.设置属性值
在system/build.prop文件中加入 ro.sf.hwrotation= 80
2.设置窗体默认显示方向
在frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp文件中找到方法
setDisplayHardware
在switch中加入
3.设置窗体动画旋转方向
a > 在frameworks/base/core/java/android/view/Surface.java 加入方法
b > 在
frameworks/base/services/java/com/android/server/vm/ScreenRotationAnimation.java 文件中找到(android4.1) 方法setRotation
或(android4.2)方法setRotationInTransaction
修改 deltaRotation(rotation,Surface.ROTATION_0);
为deltaRotation(rotation,Surface. getDefaultRotationIndex());
3 .修改最近程序视图方向
在frameworks/base/packages/systemui/src/com/android/systemui/RecentsPanelView.java 文件中修改如下
在方法中添加
在方法中添加
4.修改截屏图片方向
在frameworks/base/pacikages/systemui/src/com/android/systemui/GlobalScreenshot.java 文件中找到takeScreenshot方法
修改 float degrees = getDegreesForRotation(mDisplay.getRotation());
为
“`
int rotation = mDisplay.getRotation();
if(Surface.getDefaultRotation() > 0){
rotation = (rotation + Surface.getDefaultRotationIndex())%4;
}
float degrees = getDegreesForRotation(rotation);
OK 这样就完成屏幕旋转180度
在system/build.prop文件中加入 ro.sf.hwrotation= 80
2.设置窗体默认显示方向
在frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp文件中找到方法
setDisplayHardware
在switch中加入
case 180: displayOrientation = ISurfaceComposer::eOrientation180; break;
3.设置窗体动画旋转方向
a > 在frameworks/base/core/java/android/view/Surface.java 加入方法
/** * @hide */ public static int getDefaultRotation(){ return android.os.SystemProperties.getInt("ro.sf.hwrotation", 0);//180 } /** * @hide */ public static int getDefaultRotationIndex(){ int rotation = getDefaultRotation(); switch(rotation){ case 0: return ROTATION_0; case 90: return ROTATION_90; case 180: return ROTATION_180; case 270: return ROTATION_270; } return ROTATION_0; }
b > 在
frameworks/base/services/java/com/android/server/vm/ScreenRotationAnimation.java 文件中找到(android4.1) 方法setRotation
或(android4.2)方法setRotationInTransaction
修改 deltaRotation(rotation,Surface.ROTATION_0);
为deltaRotation(rotation,Surface. getDefaultRotationIndex());
3 .修改最近程序视图方向
在frameworks/base/packages/systemui/src/com/android/systemui/RecentsPanelView.java 文件中修改如下
private int mThumbnailHeight;//add
在方法中添加
public void updateVoluesFromResources(){ mThumbnailHeight = Math.round(res.getDimension(R.dimen.status_bar_recents_thumbnail_height));//add }
在方法中添加
private void updateThumbnail(…) { else { Matrix scaleMatrix = new Matrix(); float scale = mThumbnailWidth / (float) thumbnail.getWidth(); scaleMatrix.postScale(scale, scale);//setScale h.thumbnailViewImage.setScaleType(ScaleType.MATRIX); h.thumbnailViewImage.setImageMatrix(scaleMatrix); //add if(Surface.getDefaultRotation() > 0){ Matrix rotateMatrix = new Matrix(); rotateMatrix.setRotate(Surface.getDefaultRotation(),mThumbnailWidth/2,mThumbnailHeight/2); h.thumbnailViewImage.setImageMatrix(rotateMatrix); } //add end }
4.修改截屏图片方向
在frameworks/base/pacikages/systemui/src/com/android/systemui/GlobalScreenshot.java 文件中找到takeScreenshot方法
修改 float degrees = getDegreesForRotation(mDisplay.getRotation());
为
“`
int rotation = mDisplay.getRotation();
if(Surface.getDefaultRotation() > 0){
rotation = (rotation + Surface.getDefaultRotationIndex())%4;
}
float degrees = getDegreesForRotation(rotation);
OK 这样就完成屏幕旋转180度
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories