
本文介绍了DDMS中 Dump View Hierarchy for UI Automator 工具的使用方法,通过该工具找到一些应用的布局,快速定位我们需要修改的源码位置。
1 先看下效果图修改前,横屏状态的下拉通知栏,距离屏幕左右两边还有段距离。(模拟器中的截图,Android原生的状态)

修改后,横屏状态的下拉通知栏,宽度铺满屏幕。(真实设备截图, 修改后刷机效果)

2 找到这部分的相关布局。SystemUI下拉通知栏的布局为super_status_bar.xml

代码如下
几个关键的字眼:
| “@layout/status_bar” ————–> 状态栏
| “@+id/brightness_mirror” ——–> 下拉通知栏中调节亮度时,只剩下亮度调节弹出框,位置与下拉通知栏亮度调节位置一样的。
| “@+id/panel_holder”—————>下拉通知栏载体
| “@layout/status_bar_expanded”->下拉通知栏布局
super_status_bar.xml包含了状态栏,下拉通知栏等布局
3 找到下拉通知栏相关布局通过 DDMS 的 Dump View Hierarchy for UI Automator 工具,我们可以抓取一些布局的ID。

-3.1 header通知栏上半部分是 com.android.systemui:id/header,那我们在SystemUI的res中,搜索这个“header” 。

搜索到layout中带有header的,有status_bar_expanded_header.xml,只有这个布局有这个ID
<ol> |