今天闲的无聊,研究了下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显示名称的分析就结束了。

Launcher3 HotSeat显示名称的更多相关文章

  1. android 9.0 Launcher3 去掉抽屉式,显示所有 app

    效果图 修改思路 1.增加全局控制变量 sys.launcher3.is_full_app,用来动态切换 2.增加两套布局,对应有抽屉和无抽屉 3.去除 allAppsButton 4.将 AllAp ...

  2. (7)Launcher3客制化之,改动单屏幕后,Fix在Hotseat拖动应用删除报错

    改动单屏幕后,在workspace里面拖动图标.到删除button上松开的时候,报错问题. 而且无法再次显示拖动的图标. 拖动松开手时候触发 public void onDropCompleted(f ...

  3. Android Launcher分析和修改10——HotSeat深入进阶

    前面已经写过Hotseat分析的文章,主要是讲解如何在Launcher里面配置以及修改Hotseat的参数.今天主要是讲解一下如何在Hotseat里面的Item显示名称.这个小问题昨天折腾了半天,最后 ...

  4. 解决:HotSeat短信图标提醒有误

    [操作步骤]正常收发短信.彩信. [测试结果]所有短信均已阅读,但在HOME界面的短信图标仍提示有一条短信未读.重启后仍存在. 经过分析,导致该情况的主要原因为当彩信已读的时候,launcher中进行 ...

  5. (8)Launcher3客制化之ContentProvider内容提供者,实现其它应用改动数据库更新等操作

    首先加入两个权限 <uses-permission android:name="com.android.launcher3.permission.READ_SETTINGS" ...

  6. Silverlight 结合ArcGis 在地图画面上显示名称+ 点选图层事件委派

    原文 http://www.dotblogs.com.tw/justforgood/archive/2012/05/10/72083.aspx 如下图,我希望我的滑鼠经过此标记的点时显示名称 其实简单 ...

  7. Android launcher3 开发初始篇

    版本号:1.0 日期:2014.8.26 2014.8.27 2014.11.10 版权:© 2014 kince 转载注明出处         好久没有写博客,也是由于工作比較忙的关系.当然这不是理 ...

  8. Android Launcher分析和修改5——HotSeat分析

    今天主要是分析一下Launcher里面的快捷方式导航条——HotSeat,一般我们使用手机底下都会有这个导航条,但是如果4.0的Launcher放到平板电脑里面运行,默认是没有HotSeat的,刚好我 ...

  9. UWP 应用程序名称本地化以及商店显示名称本地化

    大家应该都知道,在做多语言的时候,我们一般会让App名字也会随着语言变化而本地化. 比如我的App微识别 https://www.microsoft.com/store/productId/9PDSN ...

随机推荐

  1. 搭建ssm项目框架

    [声明]转载注明链接,源码联系公众号:aandb7获取 [此处组织名groupId:com.dayuanit,可替换公司域名:项目名artifactid:...] 此处第二个配置文件选择maven安装 ...

  2. [LeetCode] Remove Boxes 移除盒子

    Given several boxes with different colors represented by different positive numbers. You may experie ...

  3. 解决:GitHub 远程端添加了 README.md 文件后,本地 push 代码时出现错误

    一.错误描述 To github.com:compassblog/PythonExercise.git ! [rejected] master -> master (fetch first) e ...

  4. pymysql实现从a表过滤出有效信息添加至b表

    # Author: yeshengbao # -- coding: utf-8 -- # @Time : 2018/4/16 19:23 import pymysql # 创建连接 conn = py ...

  5. [TJOI 2013]单词

    Description 题库链接 给出一篇文章的所有单词,询问每个单词出现的次数. 单词总长 \(\leq 10^6\) Solution 算是 \(AC\) 自动机的板子,注意拼成文章的时候要在单词 ...

  6. [Codeforces 863D]Yet Another Array Queries Problem

    Description You are given an array a of size n, and q queries to it. There are queries of two types: ...

  7. [WC 2011]Xor

    Description Input 第一行包含两个整数N和 M, 表示该无向图中点的数目与边的数目. 接下来M 行描述 M 条边,每行三个整数Si,Ti ,Di,表示 Si 与Ti之间存在 一条权值为 ...

  8. [HNOI2016]树

    Description 小A想做一棵很大的树,但是他手上的材料有限,只好用点小技巧了.开始,小A只有一棵结点数为N的树,结 点的编号为1,2,…,N,其中结点1为根:我们称这颗树为模板树.小A决定通过 ...

  9. ●BZOJ 4516 [Sdoi2016]生成魔咒

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=4516 题解: 把串反过来后,问题变为求每个后缀的互不相同的子串个数.首先用倍增算法求出 sa ...

  10. ●BZOJ 2669 [cqoi2012]局部极小值

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2669 题解: 容斥,DP,DFS 先看看 dp 部分:首先呢,X的个数不会超过 8个.个数很 ...