`
dss16694
  • 浏览: 144551 次
社区版块
存档分类
最新评论

miui滑动开关的移植

 
阅读更多

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" />
分享到:
评论
2 楼 dss16694 2012-06-29  
恩,对的,移植成功后我就已经发现,尝试了一下暂时没办法解决,因为miui的代码不开源,所以修改代码实现该功能可能性不大。
可以尝试去移植4.0的滑动开关,那个代码是可以下载到的,修改起来也方便。喜欢miui的效果可以通过替换相关资源实现。
1 楼 几度轮回 2012-06-26  
博主你好,关于这个滑块的移植,实际上有个bug,就是只滑动滑块从“关”到“开”的话,并没有真正“开”,对应功能还是处于“关”的状态,需要点击整个选项才能切换开关。请问怎么解决呢?

相关推荐

Global site tag (gtag.js) - Google Analytics