本教程是以sense3.0为样本。
很多人都想知道上栏和通知栏是怎么透明的,看完这个教程你就会了。
1.上栏和通知栏的透明都集中在systemui这个apk上。
首先我们要做的就是反编译systemui.apk,会得到res,smali,AndroidManifest.xml和apktool.yml四个文件,美化主要涉及到前两个文件夹。
A.找到SystemUI\smali\com\android\systemui\statusbar目录下的StatusBarService.smali文件,用记事本或Notepad++(推荐)打开,用查找工具找到“line 552”这个一行
-
- .line 552
- new-instance v0, Landroid/view/WindowManager$LayoutParams;
- const/4 v1, -0x1
- const/16 v3, 0x7d0
- const/16 v4, 0x48
- iget v5, p0, Lcom/android/systemui/statusbar/StatusBarService;->mPixelFormat:I
复制代码
将其改为
- .line 552
- new-instance v0, Landroid/view/WindowManager$LayoutParams;
-
- const/4 v1, -0x1
-
- const/16 v3, 0x7d0
-
- const/16 v4, 0x48
-
- const/4 v5, -0x3
复制代码
B.还是SystemUI\smali\com\android\systemui\statusbar目录下的StatusBarService.smali文件,用记事本或
Notepad++(推荐)打开,用查找工具找到“line 1797”这个一行
- .line 1797
- const/4 v5, 0x2
复制代码
将其改为
- .line 1797
- const/4 v5, -0x3
复制代码
C. 找到SystemUI\smali\com\android\systemui\statusbar\polic目录下的StatusBarPolicy.smali文件,用记事本或Notepad++(推荐)打开,用查找工具找到“line 2246”这个一行
- if-lt v2, v6, :cond_6
-
- const/4 v5, 0x2
复制代码
将其改为
- if-lt v2, v6, :cond_6
-
- const/4 v5, -0x3
复制代码
到此为止,smali文件夹中的文件修改结束。
D.找到SystemUI\res\layout目录下的quick_settings.xml文件,用记事本或Notepad++(推荐)打开,用查找工具找到
- “<ScrollView android:id="@id/scroll" android:fadingEdge="none" android:layout_width="fill_parent" android:layout_height="fill_parent">”
复制代码
将其改为
- “<ScrollViewandroid:id="@id/scroll"android:background="@drawable/list_item_background"
- android:fadingEdge="none"android:layout_width="fill_parent"
- android:layout_height="fill_parent">”
复制代码
E.找到SystemUI\res\layout目录下的status_bar_expanded.xml文件,用记事本或Notepad++(推荐)打开,用查找工具找到
- “<LinearLayoutandroid:orientation="vertical"android:id="@id/ongoingItems"
- android:layout_width="fill_parent"android:layout_height="wrap_content" />”
复制代码
将其改为
- “<LinearLayoutandroid:orientation="vertical"android:id="@id/ongoingItems" android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:drawable="@drawable/status_bar_background" />”
复制代码
还有
- “<LinearLayout android:orientation="vertical" android:id="@id/latestItems" android:layout_width="fill_parent" android:layout_height="wrap_content" />”
复制代码
将其改为
- “<LinearLayoutandroid:orientation="vertical"android:id="@id/latestItems"
- android:layout_width="fill_parent"android:layout_height="wrap_content"
- android:drawable="@drawable/status_bar_background"/>”
复制代码
F.找到SystemUI\res\layout目录下的status_bar_tracking.xml文件,用记事本或Notepad++(推荐)打开,用查找工具找到
- “<Viewandroid:id="@id/background"android:background="@drawable/list_item_background"
- android:layout_width="fill_parent"android:layout_height="wrap_content" android:layout_weight="1.0" />”
复制代码
将其改为
- “<Viewandroid:id="@id/background"android:background="@drawable/status_bar_background"
- android:layout_width="fill_parent"android:layout_height="wrap_content" android:layout_weight="1.0" />”
复制代码
还有
- “@drawable/divider_horizontal_light_opaque”
复制代码
将其改为
- “@drawable/divider_horizontal_dark_opaque”
复制代码
还有
- “<Viewandroid:id="@id/tab_header"android:background="@drawable/list_item_background"
复制代码
将其改为
- “<Viewandroid:id="@id/tab_header"android:background="@drawable/status_bar_background"
复制代码
还有
- “"horizontal" android:background="#ff000000”
复制代码
将其改为
- “"horizontal" android:background="#00000000”
复制代码
还有
- “textColor="#ff000000" android:ellipsize="marquee"android:gravity="center" android:id="@id/notifications"”
复制代码
改为
- “textColor="#ffffffff" android:ellipsize="marquee"android:gravity="center" android:id="@id/notifications"”
复制代码
还有
- “textColor="#ff000000" android:ellipsize="marquee"android:gravity="center" android:id="@id/quick_settings”
复制代码
改为
- “textColor="#ffffffff " android:ellipsize="marquee"android:gravity="center" android:id="@id/quick_settings”
复制代码
G. 找到SystemUI\res\values目录下的colors.xml文件,用记事本或Notepad++(推荐)打开,用查找工具找到
- “<color name="black">#ff000000</color>”
复制代码
改为
- “<color name="black">#ff999999</color>”
复制代码
还有
- “<color name="primary_text_color">#ff000000</color>”
复制代码
改为
- “<color name="primary_text_color">#ffffffff</color>”
复制代码
还有
- “<color name="secondary_text_color">#ff4c4c4c</color>”
复制代码
改为
- “<color name="secondary_text_color">#ffcccccc</color>”
复制代码
H.
找到SystemUI\res\values
目录下的drawables.xml
文件,用记事本或Notepad++
(推荐)打开,用查找工具找到
- “<item type="drawable" name="shade_bgcolor">#ff282828</item>”
复制代码
改为
- “<item type="drawable" name="shade_bgcolor">#88000000</item>”
复制代码
还有
- “<item type="drawable" name="list_item_background">#ffffffff</item>”
复制代码
改为
- “<item type="drawable" name="list_item_background">#00000000</item>”
复制代码
到此为止代码部分修改完成(好累哦),接下来就是修改图片了。
I.
找到SystemUI\res\drawable-mdpi目录,这里主要就是修改图片的透明度了。分别是status_bar_background.png(官方的这张图片是白色,你找一张黑色的或是其他自己喜欢的暗色图片-)这个是下拉栏的显示的图片,修改其透明就可以实现下拉栏的透明了。建议不要太透明,不然背景会很花的。statusbar_background.png这是上栏的透明图片,修改其透明就可以实现上栏的透明了。根据自己的需要修改。还有两张小图片,分别是status_bar_tab_off.9.png和status_bar_tab_on.9.png。因为我刚才把字体显示的颜色改成了白色,所以这两张图片就要改成暗色背景的图片了(这两张图片是9.png的图片不容易自己修改,要用特定的工具,所以建议找现成的)。官方的是白色的,字体是黑色。2.修改了好了,就要用工具编译回去了。系统文件不需要签名的。还有图片的替换最好是在编译之后进行。避免编译回去的时候发生错误。