今天闲的无聊,研究了下launcher代码,看到Hotseat.java的时候,想起来以前有做过显示hotseat中应用名称,因为换了公司代码都没拿出来,就想在试着修改,看了很久发现无从下手,记得hotseat中默认是显示应用名称的,只是hotseat位置靠下所以名称显示不出来,只要把hotseat向上移一下就可以显示出来了,可是找了半天不知道修改那个位置,只能重新研究下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显示名称的分析就结束了。

最新文章

  1. Tomcat源码导入eclipse的步骤
  2. java 客户端链接不上redis解决方案
  3. 20145330《Java程序设计》第四次实验报告
  4. Android之Button自定义点击效果
  5. Softerra LDAP Browser 使用及配置 有图有真相
  6. web.xml文件中配置ShallowEtagHeaderFilter需注意的问题
  7. jsp请求由servlet响应的方式
  8. jquery .net 无刷新多文件上传
  9. cf747 D. Winter Is Coming
  10. 数据库文件*.sdf文件定时备份,但是大小的增量在不断增长的问题排查
  11. git 的 origin 的含义
  12. HDU 3466 Proud Merchants(背包问题,要好好理解)
  13. GDI+ 或 GdiPlus 在VC6下的使用方法
  14. vsftpd服务安装配置
  15. java的list遍历
  16. Docker background
  17. Skills CodeForces - 614D (贪心)
  18. java中File的delete和deleteOnExit区别(转)
  19. Digits of Factorial LightOJ - 1045(数学题?)
  20. java多线程 -- 原子量 变量 CAS

热门文章

  1. 基于Mysql 5.7 GTID 搭建双主Keepalived 高可用
  2. 连接mysql数据库报错java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized...解决方法
  3. [LeetCode] Closest Leaf in a Binary Tree 二叉树中最近的叶结点
  4. [LeetCode] Construct the Rectangle 构建矩形
  5. 2018年Java后端面试经历
  6. [HNOI2001]矩阵乘积
  7. 51nod 1981 如何愉快地与STL玩耍
  8. C++Primer学习——动态内存
  9. ●CodeForces 280D k-Maximum Subsequence Sum
  10. Begin again