Android launcher2 让Hotseat/底部菜单栏的图标显示标题

本文介绍了如何在Android Launcher2的Hotseat中显示图标标题,通过修改Hotseat.java、CellLayout.java的源码以及调整dimens.xml文件中的高度参数来实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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,你们可以根据实际情况修改。

做完以上几步后,大功告成。


Android 4.0 Launcher2 源码 Eclipse版  :http://download.youkuaiyun.com/detail/baiyulinlin1/9620598

Android 4.0 Launcher2 源码 Eclipse版(已修改包名,不冲突系统桌面)  : http://download.youkuaiyun.com/detail/baiyulinlin1/9620601



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值