miui的设置界面中有一个比较好看的控件,即滑动开关(sliding button),而CM系列则是单调的选择框(checkingbox),今天我们要做的就是将其移植到CM系列的系统中。
1.framework-res.apk的修改
因为slidingbutton有用到几张图片,所以需要放入framework-res.apk中,将附件的slidingbutton-res.zip中的资源添加到你的framework-res中,记下各图片相应的id号。
2.framework.jar的修改
1.1.反编译/system/framework/framework.jar文件。
1.2.将附件中SlidingButton.rar中的文件全部放进反编译得到的文件夹中的/android/widget中。
1.3.打开刚才添加的文件查找资源id,一般查找0x10得到的9位号码即使资源id,然后对应你在第一步中添加的资源id进行修改,对应关系请参照miui中的对应关系,或者等我有空把所有文件中需要修改的地方标记出来。
1.3.回编译该文件夹为classes.dex,拖入framework.jar包中,至此framework.jar修改完成
3.framework-res.apk文件的修改
2.1.使用apktool将framework-res.apk反编译,修改\res\layout中的preference_widget_checkbox.xml文件,将如下代码进行修改
原代码为:
<?xml version="1.0" encoding="utf-8"?> <CheckBox android:layout_gravity="center_vertical" android:id="@id/checkbox" android:focusable="false" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="4.0dip" xmlns:android="http://schemas.android.com/apk/res/android" />
更改后的代码是:
<?xml version="1.0" encoding="utf-8"?> <SlidingButton android:layout_gravity="center_vertical" android:id="@id/checkbox" android:focusable="false" android:clickable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="4.0dip" xmlns:android="http://schemas.android.com/apk/res/android" />