Launcher3 HotSeat显示名称
2016-07-22 17:01
471 查看
今天闲的无聊,研究了下launcher代码,看到Hotseat.java的时候,想起来以前有做过显示hotseat中应用名称,因为换了公司代码都没拿出来,就想在试着修改,看了很久发现无从下手,记得hotseat中默认是显示应用名称的,只是hotseat位置靠下所以名称显示不出来,只要把hotseat向上移一下就可以显示出来了,可是找了半天不知道修改那个位置,只能重新研究下hotseat的代码了。
看hotseat.java中
mContent.setIsHotseat(true); 这个是判断是否是Hotseat的地方,简便的做法是直接修改为false,意思是这个这个不是HotSeat,那么作为普通快捷图标肯定是能显示名称的,但是这有一个问题那个allapp的名称还是没显示出来,暂时的做法是
这样hotseat就可以正常显示应用名称了。
在cellLayout.java中
发现 addview的时候会根据是否是HotSeat去显示和隐藏,但是只改这里会发现字体只显示了一半,继续跟踪
终于明白了
原来这里会通过会通过判断是否是HotSeat而去设置icon的宽高。到这里Hotseat显示名称的分析就结束了。
看hotseat.java中
@Override protected void onFinishInflate() { super.onFinishInflate(); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); mAllAppsButtonRank = grid.hotseatAllAppsRank; mContent = (CellLayout) findViewById(R.id.layout); if (grid.isLandscape && !grid.isLargeTablet()) { mContent.setGridSize(1, (int) grid.numHotseatIcons); } else { mContent.setGridSize((int) grid.numHotseatIcons, 1); } mContent.setIsHotseat(true); Log.i(TAG, "onFinishInflate,(int) grid.numHotseatIcons: " + (int) grid.numHotseatIcons); resetLayout(); }
mContent.setIsHotseat(true); 这个是判断是否是Hotseat的地方,简便的做法是直接修改为false,意思是这个这个不是HotSeat,那么作为普通快捷图标肯定是能显示名称的,但是这有一个问题那个allapp的名称还是没显示出来,暂时的做法是
allAppsButton.setText(context.getString(R.string.all_apps_button_label));
这样hotseat就可以正常显示应用名称了。
在cellLayout.java中
public void setIsHotseat(boolean isHotseat) { mIsHotseat = isHotseat; mShortcutsAndWidgets.setIsHotseat(false);} public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params, boolean markCells) { final LayoutParams lp = params; // Hotseat icons - remove text if (child instanceof BubbleTextView) { BubbleTextView bubbleChild = (BubbleTextView) child; bubbleChild.setTextVisibility(!mIsHotseat); } ... }
发现 addview的时候会根据是否是HotSeat去显示和隐藏,但是只改这里会发现字体只显示了一半,继续跟踪
mShortcutsAndWidgets.setIsHotseat(false);
终于明白了
public void setIsHotseat(boolean isHotseat) { mIsHotseatLayout = isHotseat; } int getCellContentWidth() { final LauncherAppState app = LauncherAppState.getInstance(); final DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); return Math.min(getMeasuredHeight(), mIsHotseatLayout ? grid.hotseatCellWidthPx: grid.cellWidthPx); } int getCellContentHeight() { final LauncherAppState app = LauncherAppState.getInstance(); final DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); return Math.min(getMeasuredHeight(), mIsHotseatLayout ? grid.hotseatCellHeightPx : grid.cellHeightPx); }
原来这里会通过会通过判断是否是HotSeat而去设置icon的宽高。到这里Hotseat显示名称的分析就结束了。
相关文章推荐
- 使用ViewPager实现高仿launcher左右拖动效果
- Android的Launcher启动器中添加快捷方式及小部件实例
- 基于清单的启动器的实现
- Launcher源码初探
- Andorid Launcher程序代码分析
- Android Metro风格的Launcher开发系列第一篇
- Ubuntu 下为 Idea 创建启动图标.
- CentOS7下为Eclipse添加快捷菜单
- widget相关学习
- 接收其他应用程序发出的创建快捷方式的广播
- 如何让你的APK成为开机自启动第一个APK,让它成为你的Launcher吧
- Android4.2 使preinstall中的所有应用正常显示在launcher的默认布局中
- 通过修改default_workspace.xml实现定制屏幕图表默认排列
- Launcher中配置文件夹方法
- Android 4.4 Launcher3——导入eclipse进行调试
- classload之java程序入口sun.misc.Launcher源码分析
- Android中滑屏实现----手把手教你如何实现触摸滑屏以及Scroller类详解
- Launcher workspace 应用快捷方式重复的问题
- Android应用程序的Activity启动过程简要介绍
- Android5.0源码开发之launcher切换语言后Folder和ShortcutT没有切换到当前语言