android系统定制教程,Android系统定制之SystemUI修改:下拉通知栏尺寸

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

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

63b1ae71e0a7cfa03fcef738d8a09336.gif

1.gif (201.93 KB, 下载次数: 13)

2018-7-10 09:25 上传

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

63b1ae71e0a7cfa03fcef738d8a09336.gif

2.gif (1.24 MB, 下载次数: 12)

2018-7-10 09:25 上传2 找到这部分的相关布局。

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

63b1ae71e0a7cfa03fcef738d8a09336.gif

3.png (13.4 KB, 下载次数: 15)

2018-7-10 09:30 上传

代码如下

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true">

android:id="@+id/backdrop"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:visibility="gone"

>

android:layout_width="match_parent"

android:scaleType="centerCrop"

android:layout_height="match_parent" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:scaleType="centerCrop"

android:visibility="invisible" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:importantForAccessibility="no" />

android:layout_width="match_parent"

android:layout_height="@dimen/status_bar_height" />

android:layout_width="@dimen/notification_panel_width"

android:layout_height="wrap_content"

android:layout_gravity="@integer/notification_panel_layout_gravity"

android:paddingLeft="@dimen/notification_side_padding"

android:paddingRight="@dimen/notification_side_padding"

android:visibility="gone">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:elevation="2dp"

android:background="@drawable/brightness_mirror_background">

android:layout_width="match_parent"

android:layout_height="wrap_content" />

android:id="@+id/panel_holder"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/transparent" >

android:layout_width="match_parent"

android:layout_height="match_parent"

android:visibility="gone" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:importantForAccessibility="no" />

复制代码

几个关键的字眼:

| “@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。

63b1ae71e0a7cfa03fcef738d8a09336.gif

4.png (10.96 KB, 下载次数: 13)

2018-7-10 09:30 上传-3.1 header

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

63b1ae71e0a7cfa03fcef738d8a09336.gif

5.png (49.29 KB, 下载次数: 16)

2018-7-10 09:30 上传

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

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:systemui="http://schemas.android.com/apk/res-auto"

android:id="@+id/header"

android:layout_width="@dimen/notification_panel_width"

android:layout_height="@dimen/status_bar_header_height"

android:layout_gravity="@integer/notification_panel_layout_gravity"

android:paddingStart="@dimen/notification_side_padding"

android:paddingEnd="@dimen/notification_side_padding"

android:baselineAligned="false"

android:elevation="4dp"

android:background="@drawable/notification_header_bg"

android:clickable="true"

android:focusable="true"复制代码

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

android:layout_width="@dimen/notification_panel_width"复制代码

修改为

android:layout_width="match_parent"复制代码

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

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

63b1ae71e0a7cfa03fcef738d8a09336.gif

6.png (29.68 KB, 下载次数: 15)

2018-7-10 09:30 上传

上图所示的布局代码如下

android:id="@+id/scroll_view"

android:layout_width="@dimen/notification_panel_width"

android:layout_height="match_parent"

android:layout_gravity="@integer/notification_panel_layout_gravity"

android:scrollbars="none"

android:overScrollMode="never"

android:fillViewport="true">复制代码

将宽度属性改成:

android:layout_width="match_parent"复制代码

-3.3 notification_stack_scroller

通知列表布局

63b1ae71e0a7cfa03fcef738d8a09336.gif

7.png (51.4 KB, 下载次数: 17)

2018-7-10 09:30 上传

上图所示的布局代码如下

android:id="@+id/notification_stack_scroller"

android:layout_width="@dimen/notification_panel_width"

android:layout_height="match_parent"

android:layout_gravity="@integer/notification_panel_layout_gravity"

android:layout_marginBottom="@dimen/close_handle_underlap"

android:importantForAccessibility="no" />复制代码

宽度属性改成:

android:layout_width="match_parent"复制代码

4 重新编译,打包ROM

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值