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,你們可以根據實際情況修改。
做完以上幾步後,大功告成。