android10 隐藏SystemUI锁屏下的多用户图标的示例代码
需求:如上图,需要隐藏右上角的多用户蓝色图标.
修改后结果如下:
锁屏相关的布局在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>
读者可自行查看,完毕~
到此这篇关于android10 隐藏SystemUI锁屏下的多用户图标的文章就介绍到这了,更多相关android10 隐藏多用户图标内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
以上是 android10 隐藏SystemUI锁屏下的多用户图标的示例代码 的全部内容, 来源链接: utcz.com/p/243203.html