android如何改变系统默认横竖屏方向
来源:互联网 发布:centos7 安装网络配置 编辑:程序博客网 时间:2024/05/01 11:13
在android4.2sdk上,机器默认是横屏,横屏下camera位于机器右上角,安装竖屏APK后,APK旋转180度,需要将camera位置朝下使用。
这一点不符合消费者使用习惯,需要在竖屏APK的情况下,camera位置朝上。 强制改变屏幕启动的方向,我是改的out目录下的build.prop中的ro.sf.hwrotation=90//270,不过这样改,重力感应和camera,开机logo都要翻转方向
由此引出以下开机logo的修改,原生态的logo是ppm格式的,如何修改ppm格式呢,从网上查到的信息是通过代码
具体方法如下
1. pngtopnm logo_linux_clut224.png > logo_linux_clut224.pnm
2. pnmquant 224 logo_linux_clut224.pnm > logo_linux_clut224.pnm
3.pnmtoplainpnm logo_linux_clut224.pnm > logo_linux_clut224.ppm
要删除logo_linux_clut224.c logo_linux_clut224.o 文件,重新编译内核,
注意编译完内核后,也要将上层编译下在打包,不然第一次烧录和recovery时,logo还会出现原来的现象
以下为转载部分
如何改变android默认的横竖屏,修改源码一个地方就可以了。
- public int rotationForOrientationLw(int orientation, int lastRotation,
- boolean displayEnabled) {
- if (mPortraitRotation < 0) {
- // Initialize the rotation angles for each orientation once.
- Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
- if (d.getWidth() > d.getHeight()) {
- mPortraitRotation = Surface.ROTATION_90;
- mLandscapeRotation = Surface.ROTATION_0;
- mUpsideDownRotation = Surface.ROTATION_270;
- mSeascapeRotation = Surface.ROTATION_180;
- } else {
- mPortraitRotation = Surface.ROTATION_0;
- mLandscapeRotation = Surface.ROTATION_90;
- mUpsideDownRotation = Surface.ROTATION_180;
- mSeascapeRotation = Surface.ROTATION_270;
- }
- }
- {
- Log.i(TAG, "MediaPlayer.is not PlayingVideo");
- synchronized (mLock) {
- switch (orientation) {
- case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
- //always return portrait if orientation set to portrait
- //return mPortraitRotation;
- return mUpsideDownRotation;
- case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
- //always return landscape if orientation set to landscape
- return mLandscapeRotation;
- case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT:
- //always return portrait if orientation set to portrait
- //return mUpsideDownRotation;
- return mPortraitRotation;
- case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
- //always return seascape if orientation set to reverse landscape
- return mSeascapeRotation;
- case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
- //return either landscape rotation based on the sensor
- mOrientationListener.setAllow180Rotation(
- isLandscapeOrSeascape(Surface.ROTATION_180));
- return getCurrentLandscapeRotation(lastRotation);
- case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT:
- mOrientationListener.setAllow180Rotation(
- !isLandscapeOrSeascape(Surface.ROTATION_180));
- return getCurrentPortraitRotation(lastRotation);
- }
- mOrientationListener.setAllow180Rotation(
- orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
- || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- // case for nosensor meaning ignore sensor and consider only lid
- // or orientation sensor disabled
- //or case.unspecified
- if (mLidOpen) {
- return mLidOpenRotation;
- } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) {
- return mCarDockRotation;
- } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
- return mDeskDockRotation;
- } else {
- if (useSensorForOrientationLp(orientation)) {
- return mOrientationListener.getCurrentRotation(lastRotation);
- }
- return Surface.ROTATION_0;
- }
- }
- }
- }
public int rotationForOrientationLw(int orientation, int lastRotation, boolean displayEnabled) { if (mPortraitRotation < 0) { // Initialize the rotation angles for each orientation once. Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); if (d.getWidth() > d.getHeight()) { mPortraitRotation = Surface.ROTATION_90; mLandscapeRotation = Surface.ROTATION_0; mUpsideDownRotation = Surface.ROTATION_270; mSeascapeRotation = Surface.ROTATION_180; } else { mPortraitRotation = Surface.ROTATION_0; mLandscapeRotation = Surface.ROTATION_90; mUpsideDownRotation = Surface.ROTATION_180; mSeascapeRotation = Surface.ROTATION_270; } }{Log.i(TAG, "MediaPlayer.is not PlayingVideo"); synchronized (mLock) { switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: //always return portrait if orientation set to portrait //return mPortraitRotation; return mUpsideDownRotation; case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: //always return landscape if orientation set to landscape return mLandscapeRotation; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: //always return portrait if orientation set to portrait //return mUpsideDownRotation;return mPortraitRotation; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: //always return seascape if orientation set to reverse landscape return mSeascapeRotation; case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: //return either landscape rotation based on the sensor mOrientationListener.setAllow180Rotation( isLandscapeOrSeascape(Surface.ROTATION_180)); return getCurrentLandscapeRotation(lastRotation); case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: mOrientationListener.setAllow180Rotation( !isLandscapeOrSeascape(Surface.ROTATION_180)); return getCurrentPortraitRotation(lastRotation); } mOrientationListener.setAllow180Rotation( orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); // case for nosensor meaning ignore sensor and consider only lid // or orientation sensor disabled //or case.unspecified if (mLidOpen) { return mLidOpenRotation; } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) { return mCarDockRotation; } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) { return mDeskDockRotation; } else { if (useSensorForOrientationLp(orientation)) { return mOrientationListener.getCurrentRotation(lastRotation); } return Surface.ROTATION_0; } }} }
修改上面倒数一行代码把return Surface.ROTATION_0改为你要的方向,记得这个要和上面的匹配,宽高不同,Surface.ROTATION_0也不同。因为代码开头就有
- if (mPortraitRotation < 0) {
- // Initialize the rotation angles for each orientation once.
- Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
- if (d.getWidth() > d.getHeight()) {
- mPortraitRotation = Surface.ROTATION_90;
- mLandscapeRotation = Surface.ROTATION_0;
- mUpsideDownRotation = Surface.ROTATION_270;
- mSeascapeRotation = Surface.ROTATION_180;
- } else {
- mPortraitRotation = Surface.ROTATION_0;
- mLandscapeRotation = Surface.ROTATION_90;
- mUpsideDownRotation = Surface.ROTATION_180;
- mSeascapeRotation = Surface.ROTATION_270;
- }
- }
if (mPortraitRotation < 0) { // Initialize the rotation angles for each orientation once. Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); if (d.getWidth() > d.getHeight()) { mPortraitRotation = Surface.ROTATION_90; mLandscapeRotation = Surface.ROTATION_0; mUpsideDownRotation = Surface.ROTATION_270; mSeascapeRotation = Surface.ROTATION_180; } else { mPortraitRotation = Surface.ROTATION_0; mLandscapeRotation = Surface.ROTATION_90; mUpsideDownRotation = Surface.ROTATION_180; mSeascapeRotation = Surface.ROTATION_270; } }
0 0
- android如何改变系统默认横竖屏方向
- android如何改变系统默认横竖屏方向
- android如何改变系统默认横竖屏方向
- android如何改变系统默认横竖屏方向
- android如何改变系统默认横竖屏方向
- android如何改变系统默认横竖屏方向
- android如何改变系统默认横竖屏方向
- android如何改变系统默认横竖屏方向
- android如何改变默认横竖屏方向
- 修改系统默认横竖屏
- 如何修改android开机启动默认横竖屏
- Android 开机默认横竖屏
- 修改android 默认横竖屏
- Android系统实现横竖屏两方向自动旋转的方法
- Android横竖屏切换改变布局
- Android横竖屏切换不改变生命周期
- 改变Android屏幕默认启动方向为横向
- Android系统横竖屏修改
- 计算机视觉相对容易的期刊
- MFC框架分析
- 大数运算(超长整数运算)算法的简单分析
- 输出n的因子
- IOS面试题
- android如何改变系统默认横竖屏方向
- 在MFC程序中使用控制台输出打印信息
- Linux环境下BufferedImage Graphics drawString写中文乱码的原因
- 浅析人脸检测之Haar分类器方法
- arcgis10中如何创建style文件?
- 干货:CentOS6.5_Nginx1.40_Php5.57_MySQL5.5.35编译安装全记录
- W5500评测第三弹:基于MEGA的智能家居无线转发监控主机
- thinkphp自动验证BUG问题
- QtCored4.dll 解决方法 提供这个文件所有qt版本