最近项目需要修改下拉通知栏面板的宽度,完成后,写个Blog做个总结,也提供给需要的开发人员参考。
本文介绍了DDMS中 Dump View Hierarchy for UI Automator 工具的使用方法,通过该工具找到一些应用的布局,快速定位我们需要修改的源码位置。
1 先看下效果图
修改前,横屏状态的下拉通知栏,距离屏幕左右两边还有段距离。(模拟器中的截图,Android原生的状态)
修改后,横屏状态的下拉通知栏,宽度铺满屏幕。(真实设备截图, 修改后刷机效果)
2 找到这部分的相关布局。
SystemUI下拉通知栏的布局为super_status_bar.xml
代码如下
<!-- This is the combined status bar / notification panel window. -->
<com.android.systemui.statusbar.phone.StatusBarWindowView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.android.systemui.statusbar.BackDropView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
>
<ImageView android:id="@+id/backdrop_back"
android:layout_width="match_parent"
android:scaleType="centerCrop"
android:layout_height="match_parent" />
<ImageView