状态栏显示位置 我用同一个状态栏的源码,但是放在不同尺寸大小的设备里的时候,发现状态栏显示的位置不一样,有的显示在顶部,有的显示在底部,systemui是根据哪里判断位置的显示的啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 android 4.1.2及以前版本 SystemUI根据代码判别 isTable isPhone 来显示的 android4.2.2版是手机布局 显示在最顶部 只感觉android 4.2.2 的平板好别扭~ 我问过搞SystemUI的同事了 好像要改framework层 res路径下的布局 具体的我也是不太清楚 http://asysbang.com/forum.php?mod=viewthread&tid=15&extra=page%3D1 我的源码和系统直接用作table的bar public void setInitialDisplaySize(int width, int height) { int shortSize; if (width > height) { shortSize = height; mLandscapeRotation = Surface.ROTATION_0; mSeascapeRotation = Surface.ROTATION_180; if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_reverseDefaultRotation)) { mPortraitRotation = Surface.ROTATION_90; mUpsideDownRotation = Surface.ROTATION_270; } else { mPortraitRotation = Surface.ROTATION_270; mUpsideDownRotation = Surface.ROTATION_90; } } else { shortSize = width; mPortraitRotation = Surface.ROTATION_0; mUpsideDownRotation = Surface.ROTATION_180; if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_reverseDefaultRotation)) { mLandscapeRotation = Surface.ROTATION_270; mSeascapeRotation = Surface.ROTATION_90; } else { mLandscapeRotation = Surface.ROTATION_90; mSeascapeRotation = Surface.ROTATION_270; } } // Determine whether the status bar can hide based on the size // of the screen. We assume sizes > 600dp are tablets where we // will use the system bar. int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / DisplayMetrics.DENSITY_DEVICE; mStatusBarCanHide = shortSizeDp < 600; mStatusBarHeight = mContext.getResources().getDimensionPixelSize( mStatusBarCanHide ? com.android.internal.R.dimen.status_bar_height : com.android.internal.R.dimen.system_bar_height); mHasNavigationBar = mContext.getResources().getBoolean( com.android.internal.R.bool.config_showNavigationBar); // Allow a system property to override this. Used by the emulator. // See also hasNavigationBar(). String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); if (! "".equals(navBarOverride)) { if (navBarOverride.equals("1")) mHasNavigationBar = false; else if (navBarOverride.equals("0")) mHasNavigationBar = true; } mNavigationBarHeight = mHasNavigationBar ? mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.navigation_bar_height) : 0; mNavigationBarWidth = mHasNavigationBar ? mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.navigation_bar_width) : 0; if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { mHdmiRotation = mPortraitRotation; } else { mHdmiRotation = mLandscapeRotation; } } 我分析的代码是4.1的,4.0的代码看了下应该也差不多少,控制下mHasNavigationBar 这个变量试试看有结果了 告诉我下哦 我完善下我的总结 config_showNavigationBar原来系统是false的,但是改为true后发现状态栏都不见了 mStatusBarCanHide = shortSizeDp < 600; 系统是根据这个判断来指定是显示tabletUI和PhoneUI的,还有qemu.hw.mainkeys的值 android下声音合成 tiny210 LEDDemo 怎么进入指定号码的信息列表 android 遍历 SD卡信息问题 问了一圈人,都不会,进来看看吧 android 真运行程序logcat出现乱码 难道没人研究过android上的mplayer吗?? 坑爹的Android4.4,难道我发现了系统BUG?高手来看一下 关于Gallery中WebView的3D动画效果,在线等思路 android源码编译出错(Cannot find JDK6) 求教:如何测试当前的wifi的网速? 基于Android平台淘宝网手机客户端实战开发视频教程
android 4.1.2及以前版本 SystemUI根据代码判别 isTable isPhone 来显示的 android4.2.2版是手机布局 显示在最顶部 只感觉android 4.2.2 的平板好别扭~
我问过搞SystemUI的同事了 好像要改framework层 res路径下的布局 具体的我也是不太清楚
int shortSize;
if (width > height) {
shortSize = height;
mLandscapeRotation = Surface.ROTATION_0;
mSeascapeRotation = Surface.ROTATION_180;
if (mContext.getResources().getBoolean(
com.android.internal.R.bool.config_reverseDefaultRotation)) {
mPortraitRotation = Surface.ROTATION_90;
mUpsideDownRotation = Surface.ROTATION_270;
} else {
mPortraitRotation = Surface.ROTATION_270;
mUpsideDownRotation = Surface.ROTATION_90;
}
} else {
shortSize = width;
mPortraitRotation = Surface.ROTATION_0;
mUpsideDownRotation = Surface.ROTATION_180;
if (mContext.getResources().getBoolean(
com.android.internal.R.bool.config_reverseDefaultRotation)) {
mLandscapeRotation = Surface.ROTATION_270;
mSeascapeRotation = Surface.ROTATION_90;
} else {
mLandscapeRotation = Surface.ROTATION_90;
mSeascapeRotation = Surface.ROTATION_270;
}
} // Determine whether the status bar can hide based on the size
// of the screen. We assume sizes > 600dp are tablets where we
// will use the system bar.
int shortSizeDp = shortSize
* DisplayMetrics.DENSITY_DEFAULT
/ DisplayMetrics.DENSITY_DEVICE;
mStatusBarCanHide = shortSizeDp < 600;
mStatusBarHeight = mContext.getResources().getDimensionPixelSize(
mStatusBarCanHide
? com.android.internal.R.dimen.status_bar_height
: com.android.internal.R.dimen.system_bar_height); mHasNavigationBar = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_showNavigationBar);
// Allow a system property to override this. Used by the emulator.
// See also hasNavigationBar().
String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
if (! "".equals(navBarOverride)) {
if (navBarOverride.equals("1")) mHasNavigationBar = false;
else if (navBarOverride.equals("0")) mHasNavigationBar = true;
} mNavigationBarHeight = mHasNavigationBar
? mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.navigation_bar_height)
: 0;
mNavigationBarWidth = mHasNavigationBar
? mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.navigation_bar_width)
: 0; if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) {
mHdmiRotation = mPortraitRotation;
} else {
mHdmiRotation = mLandscapeRotation;
}
}
4.0的代码看了下应该也差不多少,
控制下mHasNavigationBar 这个变量试试看
有结果了 告诉我下哦 我完善下我的总结