android10 隐藏SystemUI锁屏下的多用户图标

2020/12/24 10:10
阅读数 254

在这里插入图片描述需求:如上图,需要隐藏右上角的多用户蓝色图标.
修改后结果如下:
在这里插入图片描述

锁屏相关的布局在SystemUI

frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java

    //更新多用户图标的可见性
    private void updateVisibilities() {
   
   
        if (mMultiUserSwitch.getParent() != mStatusIconArea && !mKeyguardUserSwitcherShowing) {
   
   
            if (mMultiUserSwitch.getParent() != null) {
   
   
                getOverlay().remove(mMultiUserSwitch);
            }
            mStatusIconArea.addView(mMultiUserSwitch, 0);
        } else if (mMultiUserSwitch.getParent() == mStatusIconArea && mKeyguardUserSwitcherShowing) {
   
   
            mStatusIconArea.removeView(mMultiUserSwitch);
        }
        if (mKeyguardUserSwitcher == null) {
   
   
            // If we have no keyguard switcher, the screen width is under 600dp. In this case,
            // we only show the multi-user switch if it's enabled through UserManager as well as
            // by the user.
            //控制其显示还是不显示
            if (mMultiUserSwitch.isMultiUserEnabled()) {
   
   
                mMultiUserSwitch.setVisibility(View.VISIBLE);
            } else {
   
   
                mMultiUserSwitch.setVisibility(View.GONE);
            }
        }
        //直接使其不显示就可以生效
        mMultiUserSwitch.setVisibility(View.GONE);
        mBatteryView.setForceShowPercent(mBatteryCharging && mShowPercentAvailable);
    }

mMultiUserSwitch就是显示多用户的控件,对应的代码在
frameworks/base/packages/SystemUI/res/layout/keyguard_status_bar.xml

        <com.android.systemui.statusbar.phone.MultiUserSwitch android:id="@+id/multi_user_switch"
            android:layout_width="@dimen/multi_user_switch_width_keyguard"
            android:layout_height="match_parent"
            android:background="@drawable/ripple_drawable"
            android:layout_marginEnd="@dimen/multi_user_switch_keyguard_margin">
            <ImageView android:id="@+id/multi_user_avatar"
                android:layout_width="@dimen/multi_user_avatar_keyguard_size"
                android:layout_height="@dimen/multi_user_avatar_keyguard_size"
                android:layout_gravity="center"
                android:scaleType="centerInside"/>
        </com.android.systemui.statusbar.phone.MultiUserSwitch>

读者可自行查看,完毕~

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部