a20隐藏底部按钮及隐藏状态栏和虚拟按键栏

隐藏RecentButton按钮:

在源码android4.2/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java的makeStatusBarView()方法中添加(这是全志android4.2.2版本(SDK1.3)的路径)

{Z:\A20_V3.0.1\android\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\NavigationBarView.java这是全志android4.2.2版本(SDK3.0)的路径}

mRecentButton.setVisibility(View.GONE);

代码位置(makeStatusBarView()方法中):

        // The navigation buttons
        mBackButton = (ImageView)sb.findViewById(R.id.back);
        mNavigationArea = (ViewGroup) sb.findViewById(R.id.navigationArea);
        mHomeButton = mNavigationArea.findViewById(R.id.home);
        mMenuButton = mNavigationArea.findViewById(R.id.menu);
        mVolumeDownButton = mNavigationArea.findViewById(R.id.volume_down);
        mVolumeUpButton = mNavigationArea.findViewById(R.id.volume_up);
        mRecentButton = mNavigationArea.findViewById(R.id.recent_apps);
        mRecentButton.setOnClickListener(mOnClickListener);
                mRecentButton.setVisibility(View.GONE);//wangjian
        
        mScreenShotButton = mNavigationArea.findViewById(R.id.screenshot);
        mScreenShotButton.setOnClickListener(mOnClickListener);
        
        LayoutTransition lt = new LayoutTransition();
        lt.setDuration(250);

我没有验证留下一下代码的可行性,为了保险我屏蔽了setNavigationVisibility(int visibility)方法中的

mRecentButton.setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);

这段代码,位置如下(橘色部分):


    private void setNavigationVisibility(int visibility) {
        boolean disableHome = ((visibility & StatusBarManager.DISABLE_HOME) != 0);
        boolean disableRecent = ((visibility & StatusBarManager.DISABLE_RECENT) != 0);
        boolean disableBack = ((visibility & StatusBarManager.DISABLE_BACK) != 0);

        
        boolean disableVolumeUp = (visibility != 0);
        boolean disableVolumeDown = (visibility != 0);
        
        mBackButton.setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
        mHomeButton.setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
        //mRecentButton.setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);


        
        if(mContext.getResources().getBoolean(R.bool.hasVolumeButton))
        {
            mVolumeUpButton.setVisibility(disableVolumeUp ? View.INVISIBLE : View.VISIBLE);
            mVolumeDownButton.setVisibility(disableVolumeDown ? View.INVISIBLE : View.VISIBLE);
        }

这样就可隐藏RecentButton,隐藏MenuButton,screenshot按钮方法如下:

在源码android4.2/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarView.java中

将所有         menu.setVisibility(View.VISIBLE);
                screenshot.setVisibility(View.VISIBLE);两个设置改为

                menu.setVisibility(View.GONE);
                screenshot.setVisibility(View.GONE);

这个方法比较蠢,但管用!可以试试!

如果要彻底隐藏状态栏和底部虚拟按键可以在

android\frameworks\base\core\res\res\values\dimens.xml中将status_bar_height、navigation_bar_height、navigation_bar_height_landscape这三个值改为0即可,如下:

    <dimen name="status_bar_height">0dip</dimen>

    <!-- Height of the bottom navigation / system bar. -->

    <dimen name="navigation_bar_height">0dp</dimen>

    <!-- Height of the bottom navigation bar in portrait; often the same as @dimen/navigation_bar_height -->

    <dimen name="navigation_bar_height_landscape">0dp</dimen>


你可能感兴趣的:(a20隐藏底部按钮及隐藏状态栏和虚拟按键栏)