我用同一个状态栏的源码,但是放在不同尺寸大小的设备里的时候,发现状态栏显示的位置不一样,有的显示在顶部,有的显示在底部,systemui是根据哪里判断位置的显示的啊

解决方案 »

  1.   


    android 4.1.2及以前版本  SystemUI根据代码判别 isTable  isPhone 来显示的   android4.2.2版是手机布局 显示在最顶部   只感觉android 4.2.2 的平板好别扭~
      

  2.   


    我问过搞SystemUI的同事了  好像要改framework层 res路径下的布局    具体的我也是不太清楚
      

  3.   

    http://asysbang.com/forum.php?mod=viewthread&tid=15&extra=page%3D1
      

  4.   

    我的源码和系统直接用作table的bar
      

  5.   

     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;
            }
        }
      

  6.   

    我分析的代码是4.1的,
    4.0的代码看了下应该也差不多少,
    控制下mHasNavigationBar  这个变量试试看
    有结果了 告诉我下哦 我完善下我的总结
      

  7.   

    config_showNavigationBar原来系统是false的,但是改为true后发现状态栏都不见了
      

  8.   

    mStatusBarCanHide = shortSizeDp < 600;  系统是根据这个判断来指定是显示tabletUI和PhoneUI的,还有qemu.hw.mainkeys的值