launcher3的hotseat的图标文字处理

隐藏文件夹图标的 标题文字

packages\apps\Launcher3\src\com\android\launcher3\Workspace.java

void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY,
            boolean insert, boolean computeXYFromRank) {

...

            // Hide folder title in the hotseat
            if (child instanceof FolderIcon) {
                ((FolderIcon) child).setTextVisible(false);
            }

            if (computeXYFromRank) {
                x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);
                y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);
            } else {
                screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);
            }
        } else {
            // Show folder title if not in the hotseat
            if (child instanceof FolderIcon) {
                //((FolderIcon) child).setTextVisible(true);
                ((FolderIcon) child).setTextVisible(false); //modefied by xun 
            }

...

}


添加快捷键图标的 标题文字

packages\apps\Launcher3\src\com\android\launcher3\CellLayout.java

 public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params,
            boolean markCells) {

...

        // Hotseat icons - remove text
        if (child instanceof BubbleTextView) {
            BubbleTextView bubbleChild = (BubbleTextView) child;
           // bubbleChild.setTextVisibility(!mIsHotseat);

bubbleChild.setTextVisibility(true);   //true为显示
        }

...

}

如果还是没有显示那是因为hotseat高度太小了.packages\apps\Launcher3\src\com\android\launcher3\DynamicGrid.java

// Hotseat
        hotseatBarHeightPx = iconSizePx + 25 * edgeMarginPx;//设置高度


添加allAppsbutton 文字

packages\apps\Launcher3\src\com\android\launcher3\Hotseat.java

    void resetLayout() {

            LayoutInflater inflater = LayoutInflater.from(context);
            TextView allAppsButton = (TextView)
                    inflater.inflate(R.layout.all_apps_button, mContent, false);
            Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
            Utilities.resizeIconDrawable(d);
            allAppsButton.setCompoundDrawables(null, d, null, null);

            allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
            allAppsButton.setText(context.getString(R.string.all_apps_button_label));  //添加文字

}

all_apps_button.xml 文件修改

<item name="android:textSize">28dp</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">3</item>

<item name="android:shadowRadius">4.0</item>
<item name="android:shadowColor">#ee000000</item>

以上这样,虽然能把文字显示出来,但是发现文字的大小和位置都和其他的图标不一样,整体看起来很别扭。所以还要修改下

由于launcher桌面的图标文字是有类 BubbleTextView 完成的,所以在这里让 allAppsButton 继承 BubbleTextView 而不是原先的TextView 。

如下:

    void resetLayout() {
        mContent.removeAllViewsInLayout();
        if (!AppsCustomizePagedView.DISABLE_ALL_APPS) {
            // Add the Apps button
            Context context = getContext();
            LayoutInflater inflater = LayoutInflater.from(context);
            BubbleTextView allAppsButton = (BubbleTextView)
                    inflater.inflate(R.layout.all_apps_button, mContent, false);
            Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
            Utilities.resizeIconDrawable(d);
            allAppsButton.setCompoundDrawables(null, d, null, null);
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
allAppsButton.setCompoundDrawablePadding((int) ((grid.folderIconSizePx - grid.iconSizePx) / 2f)); 
allAppsButton.setText(context.getString(R.string.all_apps_button_label));  //
            allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));

...

}

packages\apps\Launcher3\res\layout\all_apps_button.xml

<com.android.launcher3.BubbleTextView 

   xmlns:android="http://schemas.android.com/apk/res/android"
   style="@style/WorkspaceIcon"
   android:focusable="true"
   android:background="@drawable/focusable_view_bg" />


这样就和旁边的一样来了。




  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值