android10 隐藏SystemUI锁屏下的多用户图标的示例代码
程序员文章站
2022-07-02 23:51:58
需求:如上图,需要隐藏右上角的多用户蓝色图标.修改后结果如下:锁屏相关的布局在systemuiframeworks/base/packages/systemui/src/com/android/sys...
需求:如上图,需要隐藏右上角的多用户蓝色图标.
修改后结果如下:
锁屏相关的布局在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 隐藏多用户图标内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!