本文转载自:https://blog.csdn.net/huil0925/article/details/67632358

最近项目需要修改下拉通知栏面板的宽度,完成后,写个Blog做个总结,也提供给需要的开发人员参考。


本文介绍了DDMS中 Dump View Hierarchy for UI Automator 工具的使用方法,通过该工具找到一些应用的布局,快速定位我们需要修改的源码位置。

1 先看下效果图

修改前,横屏状态的下拉通知栏,距离屏幕左右两边还有段距离。(模拟器中的截图,Android原生的状态) 

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

2 找到这部分的相关布局。

SystemUI下拉通知栏的布局为super_status_bar.xml 

代码如下

  1. <!-- This is the combined status bar / notification panel window. -->
  2. <com.android.systemui.statusbar.phone.StatusBarWindowView
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:fitsSystemWindows="true">
  7. <com.android.systemui.statusbar.BackDropView
  8. android:id="@+id/backdrop"
  9. android:layout_width="match_parent"
  10. android:layout_height="match_parent"
  11. android:visibility="gone"
  12. >
  13. <ImageView android:id="@+id/backdrop_back"
  14. android:layout_width="match_parent"
  15. android:scaleType="centerCrop"
  16. android:layout_height="match_parent" />
  17. <ImageView android:id="@+id/backdrop_front"
  18. android:layout_width="match_parent"
  19. android:layout_height="match_parent"
  20. android:scaleType="centerCrop"
  21. android:visibility="invisible" />
  22. </com.android.systemui.statusbar.BackDropView>
  23. <com.android.systemui.statusbar.ScrimView android:id="@+id/scrim_behind"
  24. android:layout_width="match_parent"
  25. android:layout_height="match_parent"
  26. android:importantForAccessibility="no" />
  27. <include layout="@layout/status_bar"
  28. android:layout_width="match_parent"
  29. android:layout_height="@dimen/status_bar_height" />
  30. <FrameLayout android:id="@+id/brightness_mirror"
  31. android:layout_width="@dimen/notification_panel_width"
  32. android:layout_height="wrap_content"
  33. android:layout_gravity="@integer/notification_panel_layout_gravity"
  34. android:paddingLeft="@dimen/notification_side_padding"
  35. android:paddingRight="@dimen/notification_side_padding"
  36. android:visibility="gone">
  37. <FrameLayout
  38. android:layout_width="match_parent"
  39. android:layout_height="match_parent"
  40. android:elevation="2dp"
  41. android:background="@drawable/brightness_mirror_background">
  42. <include layout="@layout/quick_settings_brightness_dialog"
  43. android:layout_width="match_parent"
  44. android:layout_height="wrap_content" />
  45. </FrameLayout>
  46. </FrameLayout>
  47. <com.android.systemui.statusbar.phone.PanelHolder
  48. android:id="@+id/panel_holder"
  49. android:layout_width="match_parent"
  50. android:layout_height="match_parent"
  51. android:background="@color/transparent" >
  52. <include layout="@layout/status_bar_expanded"
  53. android:layout_width="match_parent"
  54. android:layout_height="match_parent"
  55. android:visibility="gone" />
  56. </com.android.systemui.statusbar.phone.PanelHolder>
  57. <com.android.systemui.statusbar.ScrimView android:id="@+id/scrim_in_front"
  58. android:layout_width="match_parent"
  59. android:layout_height="match_parent"
  60. android:importantForAccessibility="no" />
  61. </com.android.systemui.statusbar.phone.StatusBarWindowView>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68

几个关键的字眼: 
| “@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

  1. <com.android.systemui.statusbar.phone.StatusBarHeaderView
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:systemui="http://schemas.android.com/apk/res-auto"
  4. android:id="@+id/header"
  5. android:layout_width="@dimen/notification_panel_width"
  6. android:layout_height="@dimen/status_bar_header_height"
  7. android:layout_gravity="@integer/notification_panel_layout_gravity"
  8. android:paddingStart="@dimen/notification_side_padding"
  9. android:paddingEnd="@dimen/notification_side_padding"
  10. android:baselineAligned="false"
  11. android:elevation="4dp"
  12. android:background="@drawable/notification_header_bg"
  13. android:clickable="true"
  14. android:focusable="true"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

如果需要修改header的尺寸,可将

  1. android:layout_width="@dimen/notification_panel_width"
  • 1

修改为

  1. android:layout_width="match_parent"
  • 1

重新编译,这个header的宽度就和屏幕一样了。

-3.2 scroll_view

可上下滑动的快捷开关布局。 

上图所示的布局代码如下

  1. <com.android.systemui.statusbar.phone.ObservableScrollView
  2. android:id="@+id/scroll_view"
  3. android:layout_width="@dimen/notification_panel_width"
  4. android:layout_height="match_parent"
  5. android:layout_gravity="@integer/notification_panel_layout_gravity"
  6. android:scrollbars="none"
  7. android:overScrollMode="never"
  8. android:fillViewport="true">
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

将宽度属性改成:

  1. android:layout_width="match_parent"
  • 1

-3.3 notification_stack_scroller

通知列表布局 

上图所示的布局代码如下

  1. <com.android.systemui.statusbar.stack.NotificationStackScrollLayout
  2. android:id="@+id/notification_stack_scroller"
  3. android:layout_width="@dimen/notification_panel_width"
  4. android:layout_height="match_parent"
  5. android:layout_gravity="@integer/notification_panel_layout_gravity"
  6. android:layout_marginBottom="@dimen/close_handle_underlap"
  7. android:importantForAccessibility="no" />
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

宽度属性改成:

  1. android:layout_width="match_parent"
  • 1

4 重新编译,打包ROM

make源码,重新刷机查看效果,可以看到文章开头的gif图所示的效果

Android系统定制之SystemUI修改:下拉通知栏尺寸【转】的更多相关文章

  1. Android系统定制和源码开发以及源码编译(附视频)

    Android系统定制配套视频: 为了把Android系统源码定制和编译的课程讲完,从准备到录制完所有的视频,一共花去了近半年的时间,前前后后各种下载源码,编译源码,系统不兼容,版本适配,虚拟机配置困 ...

  2. [置顶] android系统如何在静音模式下关闭camera拍照声音(2)

    之前写过一篇“android系统如何在静音模式下关闭camera拍照声音”的博客,今天来写他的续篇,继续探讨这个问题. 公司新需求,要求在camera应用中添加一个开关,可以进行拍照声音的关闭和开启. ...

  3. SupportV7包中 SwipeRefreshLayout 修改下拉控件的距离

    //修改下拉距离 ViewTreeObserver vto = mCategoryResults.mSwipeRefreshLayout.getViewTreeObserver(); vto.addO ...

  4. bootstrap-select and selectpicker 修改下拉框的宽度或者下方留白

    bootstrap-select and selectpicker 修改下拉框的宽度或者下方留白 $("#sel_userName").selectpicker({ "w ...

  5. QuickBase64 - Android 下拉通知栏快捷base64加解密工具

    Android Quick Setting Tile Base64 Encode/Decode Tool Android 下拉通知栏快捷 base64 加解密,自动将剪切板的内容进行 base64 E ...

  6. Android 系统默认参数的修改

    转自: http://www.th7.cn/Program/Android/201505/447097.shtml 写在前面的话 一般在新项目开始之初,我们需要针对客户需求进行各种系统默认属性的配置, ...

  7. Android系统定制——Download Android System 及加载system镜像文件

    定制android系统(配置及相关系统的镜像文件),具体可参考:Driver_All_in_One_V1.0——MT6735_6753.pdf文档,特别需要理解的是Download部分. 与之对应的软 ...

  8. Android系统联系人全特效实现(下),字母表快速滚动

    在上一篇文章中,我和大家一起实现了类似于Android系统联系人的分组导航和挤压动画功能,不过既然文章名叫做<Android系统联系人全特效实现>,那么没有快速滚动功能显然是称不上&quo ...

  9. PullToRefreshScrollView 修改下拉刷新图标

    我的修改比较简单暴力.网上查了一番,貌似大家都没有改,无奈,查了一下源码.发现如下资源目录: 在看看我们的布局文件,此三个图片就是下拉刷新的三种图标 好吧,flip就是我目前的下拉刷新图片,对应的也就 ...

随机推荐

  1. HTTP协议断点续传

    using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;usi ...

  2. GoogleMap的鼠标点击标注、搜索和设置城市的简单应用

    资源 Google Map API包含了大量的文档.示例和各种资料.在使用前需要申请自己的密钥 墙内要用:http://maps.google.cn/maps/api/js? 墙外可用:https:/ ...

  3. Python之比较运算符

    python中的比较运算符有8个. 运算 | 含义=============< | 小于<= | 小于等于> | 大于>= |大于等于== | 等于!= |不等于is | 是i ...

  4. lua学习笔记(六)

    (2012-04-12 23:32:35) 转载▼   函数  定义     function mytest(a,b,c) <函数体> end     mytest = function( ...

  5. python的requests初步使用

    转自:http://my.oschina.net/yangyanxing/blog/280029 早就听说requests的库的强大,只是还没有接触,今天接触了一下,发现以前使用urllib,urll ...

  6. FPGA开发流程

    需求说明:Verilog设计 内容       :FPGA开发基本流程及注意事项 来自       :时间的诗 原文来自:http://www.dzsc.com/data/2015-3-16/1080 ...

  7. 在Windows 10中开启开发者模式

    及以上)的电脑上使用Visual Studio来开发Windows 10或者Windows 8.1的应用,你可能会遇到下面的问题,要求你开启开发者模式. 于是你跑到设置里面,把开发者模式打开: 结果你 ...

  8. Codeforces 38G Queue 伸展树

    题目链接:点击打开链接 题意: 给定n个人来排队 每一个人有2个參数.身份优先级和脸皮厚度 == 来的那个人会排到队尾 假设这个人的优先级比他前面那个人的优先级大就会和前面那个人交换位置. 交换一次脸 ...

  9. bg、fg、nohup

    1.bg 执行如下命令: tail -f log.txt 此时程序是在前台运行的,将程序放到后台执行,按ctrl+z,执行结果如下: []+ Stopped tail -f log.txt 执行bg命 ...

  10. Call to static DateFormat

    Bug: Call to method of static java.text.DateFormatPattern id: STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INS ...