android10 隱藏SystemUI鎖屏下的多用戶圖標(biāo)的示例代碼

需求:如上圖,需要隱藏右上角的多用戶藍(lán)色圖標(biāo).
修改后結(jié)果如下:

鎖屏相關(guān)的布局在SystemUI
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
//更新多用戶圖標(biāo)的可見性
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就是顯示多用戶的控件,對(duì)應(yīng)的代碼在
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>
讀者可自行查看,完畢~
到此這篇關(guān)于android10 隱藏SystemUI鎖屏下的多用戶圖標(biāo)的文章就介紹到這了,更多相關(guān)android10 隱藏多用戶圖標(biāo)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Android?Flutter實(shí)現(xiàn)"斑馬紋"背景的示例代碼
本文將通過實(shí)現(xiàn)一個(gè)canvas繪制斑馬紋類。使用Stack布局,將斑馬紋放在下方作為背景板,需要展示的內(nèi)容在上方。從而實(shí)現(xiàn)?“斑馬紋”背景,感興趣的可以了解一下2022-06-06
Android中Listview下拉刷新和上拉加載更多的多種實(shí)現(xiàn)方案
本文大概通過三種方案給大家介紹了Android中Listview下拉刷新和上拉加載更多知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下2016-12-12
Android 判斷某個(gè)Activity 是否在前臺(tái)運(yùn)行的實(shí)例
下面小編就為大家分享一篇Android 判斷某個(gè)Activity 是否在前臺(tái)運(yùn)行的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-03-03
Grow heap (frag case) 堆內(nèi)存過大的深入解析
本篇文章是對(duì)Grow heap (frag case) 堆內(nèi)存過大的問題進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
Android開發(fā)技巧之永不關(guān)閉的Toast信息框(長(zhǎng)時(shí)間顯示而非系統(tǒng)關(guān)閉)
Toast信息提示框之所以在顯示一定時(shí)間后會(huì)自動(dòng)關(guān)閉,是因?yàn)樵谙到y(tǒng)中有一個(gè)Toast隊(duì)列;那么有些時(shí)候需要這個(gè)Toast信息提示框長(zhǎng)時(shí)間顯示,直到需要關(guān)閉它時(shí)通過代碼來控制,而不是讓系統(tǒng)自動(dòng)來關(guān)閉Toast信息提示框2013-01-01
Android TextWatcher三個(gè)回調(diào)以及監(jiān)聽EditText的輸入案例詳解
這篇文章主要介紹了Android TextWatcher三個(gè)回調(diào)以及監(jiān)聽EditText的輸入案例詳解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08

