Android--隱藏狀態列圖示
阿新 • • 發佈:2019-01-24
目前狀態列圖示有通知圖示和系統圖標通知圖示主要是指各應用發過來的通知,比如未接電話,截圖,後臺播放音樂等,系統圖標主要有藍芽,耳機,wifi,資料流量,時間和電池...1,不顯示通知圖示,在/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java中public void updateNotificationIcons {
for (int i = 0; i < N; i++) { NotificationData.Entry ent = activeNotifications.get(i); + final String pkg = ent.notification.getPackageName(); + android.util.Log.d("StatusBarIconController","pkg========"+pkg);
//比如如果包名不是收音機的,就不顯示圖示 + if (!pkg.contains("com.android.fmradio")) { + continue; } if (notificationData.isAmbient(ent.key) && !NotificationData.showNotificationEvenIfUnprovisioned(ent.notification)) { continue; }}
2.不顯示系統圖標,系統圖標的顯示是在以下檔案,比如藍芽,wifi,耳機等/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
將不要顯示圖示,將setIconVisibility()改為false即可,比如,如果不要鬧鐘圖示private void updateAlarm() { ....- - - mService.setIconVisibility(SLOT_ALARM_CLOCK, mCurrentUserSetup && hasAlarm);
+++ mService.setIconVisibility(SLOT_ALARM_CLOCK, false); }3,系統圖標中比較特殊的時間和電池在/frameworks/base/packages/SystemUI/res/layout/status_bar.xml<com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:paddingStart="7dp" android:gravity="center_vertical|start"+++ android:visibility="gone" //時間 />/frameworks/base/packages/SystemUI/res/layout/system_icons.xml
<com.android.systemui.BatteryMeterView android:id="@+id/battery" android:layout_height="14.5dp" android:layout_width="9.5dp"+++ android:visibility="gone" 電池 android:layout_marginBottom="@dimen/battery_margin_bottom"/>
for (int i = 0; i < N; i++) { NotificationData.Entry ent = activeNotifications.get(i); + final String pkg = ent.notification.getPackageName(); + android.util.Log.d("StatusBarIconController","pkg========"+pkg);
//比如如果包名不是收音機的,就不顯示圖示 + if (!pkg.contains("com.android.fmradio")) { + continue; } if (notificationData.isAmbient(ent.key) && !NotificationData.showNotificationEvenIfUnprovisioned(ent.notification)) { continue; }}
2.不顯示系統圖標,系統圖標的顯示是在以下檔案,比如藍芽,wifi,耳機等/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
將不要顯示圖示,將setIconVisibility()改為false即可,比如,如果不要鬧鐘圖示private void updateAlarm() { ....- - - mService.setIconVisibility(SLOT_ALARM_CLOCK, mCurrentUserSetup && hasAlarm);
+++ mService.setIconVisibility(SLOT_ALARM_CLOCK, false); }3,系統圖標中比較特殊的時間和電池在/frameworks/base/packages/SystemUI/res/layout/status_bar.xml<com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:textAppearance="@style/TextAppearance.StatusBar.Clock" android:layout_width="wrap_content" android:layout_height="match_parent" android:singleLine="true" android:paddingStart="7dp" android:gravity="center_vertical|start"+++ android:visibility="gone" //時間 />/frameworks/base/packages/SystemUI/res/layout/system_icons.xml
<com.android.systemui.BatteryMeterView android:id="@+id/battery" android:layout_height="14.5dp" android:layout_width="9.5dp"+++ android:visibility="gone" 電池 android:layout_marginBottom="@dimen/battery_margin_bottom"/>