Launcher3 HotSeat显示名称
2016-07-22 17:01
183 查看
今天闲的无聊,研究了下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显示名称的分析就结束了。
相关文章推荐
- [笔记]--Redhat5.6安装Oracle11gR2
- 9张思维导图学习Javascript(转)
- ROS_Xmlrpc++ 简单示例
- SDUT 3343 数据结构实验之二叉树四:还原二叉树
- 【VS开发】循序渐进学习使用WINPCAP(一)
- vs2012 未能加载visual c++ language manager package
- 观察者模式
- spring roo 开发meavn项目(五)后台发送邮件功能
- gcc工具使用
- iOS 10 个实用小技巧(总有你不知道的和你会用到的)
- Handler的深入了解
- 如何搭建Java开发环境(包括下载、安装和配置JDK)和Eclipse的安装
- Python 学习笔记三 操作PostgreSQL数据库
- poj 3126 队列 且行且珍惜---
- encodeURI和encodeURIComponent
- Hibernate 4 Second Level Caching With EHCache
- HTML5开发Android程序
- 腾讯云TAB缘何一跃成为开发者新宠?
- JBOSS调试启动报错 classic VM not supported; client VM will be used Unrecognized option: -
- Android Studio工具修理集