您的位置:首页 > 移动开发 > Android开发

修改Launcher3的Hotseat的位置到右侧的方法

2016-12-08 09:41 393 查看
Launcher3的代码和Launcher2差不多,不管是UI布局还是代码设计,都还蛮复杂的,要想彻底搞清楚需要不少时间。

这里就简单记录一下把Launcher3的Hotseat修改到右侧的方法(本来Hotseat是在底部的)。

先来看效果,android4.4的Launcher3修改后的效果:



android5.1的Launcher3修改后的效果:



下面说一下修改点,共有2处:

修改点1:

把文件android/packages/apps/Launcher3/res/values-sw720dp/config.xml中的hotseat_transpose_layout_with_orientation由false改为true:

<!-- Hotseat -->
-    <bool name="hotseat_transpose_layout_with_orientation">false</bool>
+    <bool name="hotseat_transpose_layout_with_orientation">true</bool>
</resources>


我的平板是改的sw720dp目录中的,保险起见应该把res目录下的所有config.xml中的这个值都改为true。

修改点2:

修改文件android/packages/apps/Launcher3/src/com/android/launcher3/Hotseat.java 
public class Hotseat extends FrameLayout {
mAllAppsButtonRank = grid.hotseatAllAppsRank;
mContent = (CellLayout) findViewById(R.id.layout);

+        mContent.setGridSize(1, (int) grid.numHotseatIcons);    //AA
+        /*
if (grid.isLandscape && !grid.isLargeTablet()&&!grid.isTablet()) {
mContent.setGridSize(1, (int) grid.numHotseatIcons);   //BB
} else {
mContent.setGridSize((int) grid.numHotseatIcons, 1);
}
+        */

mContent.setIsHotseat(true);
resetLayout();

上面新增的AA行其实就是拷贝的BB行,目的就是让流程固定走BB分支(这里我改的比较简单粗暴,各位可自行修改判断条件以达到相同目的)

如果你发现有更简单直观的方法,也请不吝赐教,谢谢!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android Launcher3 Hotseat