Launcher2的hotseat中的图标是不带标题,有些人可能觉得不够美观或者体验不好,这里我尝试地去找了一下可能原因,Hotseat之所以没能显示标题,可能由于以下因素:
1、hotseat的高度不够高
2、hotseat的标题没有设置
3、hotseat的标题被隐藏起来了
好了大概的原因就这些,根据以下步骤修改就行了。

1、Hotseat.java,找到resetLayout()方法,添加 allAppsButton.setText(R.string.all_apps_button_label);
-
void resetLayout() { -
mContent.removeAllViewsInLayout(); -
Context context = getContext(); -
LayoutInflater inflater = LayoutInflater.from(context); -
BubbleTextView allAppsButton = (BubbleTextView) inflater.inflate( -
R.layout.application, mContent, false); -
allAppsButton.setCompoundDrawablesWithIntrinsicBounds(null, context -
.getResources().getDrawable(R.drawable.all_apps_button_icon), -
null, null); -
allAppsButton.setContentDescription(context -
.getString(R.string.all_apps_button_label)); -
//添加 -
allAppsButton.setText(R.string.all_apps_button_label); -
allAppsButton.setOnTouchListener(new View.OnTouchListener() { -
@Override -
public boolean onTouch(View v, MotionEvent event) { -
if (mLauncher != null -
&& (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { -
mLauncher.onTouchDownAllAppsButton(v); -
} -
return false; -
} -
});
2、CellLayout.java,找到addViewToCellLayout()方法,注释掉 if (child instanceof BubbleTextView) {}部分
-
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; -
// -
// Resources res = getResources(); -
// if (mIsHotseat) { -
// bubbleChild.setTextColor(res.getColor(android.R.color.transparent)); -
// } else { -
// bubbleChild.setTextColor(res.getColor(R.color.workspace_icon_text_color)); -
// } -
// } -
child.setScaleX(getChildrenScale()); -
child.setScaleY(getChildrenScale());
3、分别修改res/values/dimens.xml、res/values-land/dimens.xml、res/values-sw600dp/dimens.xml这3个dimens中的hotseat_cell_height的值,这里我是统一给他们加30dp,你们可以根据实际情况修改。
做完以上几步后,大功告成。
本文介绍如何解决Launcher2中Hotseat图标不显示标题的问题。通过修改Hotseat.java和CellLayout.java文件,并调整dimens.xml文件中的hotseat_cell_height参数,可以成功使Hotseat图标显示标题。
688

被折叠的 条评论
为什么被折叠?



