亲宝软件园·资讯

展开

android10 隐藏多用户图标 android10 隐藏SystemUI锁屏下的多用户图标的代码实例

鸣人的修炼场 人气:1

在这里插入图片描述

需求:如上图,需要隐藏右上角的多用户蓝色图标.
修改后结果如下:

在这里插入图片描述

锁屏相关的布局在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>

读者可自行查看,完毕~

加载全部内容

相关教程
猜你喜欢
用户评论