Launcher3添加左屏及去除全部应用列表界面 .

国内rom效仿ios的风格,只有一个桌面,咋看起来对于rom开发者是件很费神的事情,但其实android已经提供了一个宏,来定义是否显示应用程序列表,我们只要把AppsCustomizePagedView.java下的DISABLE_ALL_APPS值改为true,应用程序列表就消失了,而所有应用的图标都显示在了桌面上。


在一些品牌手机上,我们经常可以看到在桌面的最左边,有诸如资讯浏览、地图、天气等功能。 Launcher3也提供了快捷增加左屏的接口,可以很方便的实现这个功能。只需修改Launcher.java,或者用一个子类继承Launcher,并重写hasCustomContentToLeft和addCustomContentToLeft即可实现效果,在addCustomContentToLeft方法中,通过调用Launcher.addToCustomContentPage方法,将自定义view添加至桌面左屏。具体实现如代码:


/**
	 * To be overriden by subclasses to hint to Launcher that we have custom
	 * content
	 */
	protected boolean hasCustomContentToLeft() {
		return true;
	}

	/**
	 * To be overridden by subclasses to create the custom content and call
	 * {@link #addToCustomContentPage}. This will only be invoked if
	 * {@link #hasCustomContentToLeft()} is {@code true}.
	 */
	protected void addCustomContentToLeft() {
		View customView = getLayoutInflater().inflate(R.layout.custom, null);
        CustomContentCallbacks callbacks = new CustomContentCallbacks() {
            @Override
            public void onShow() {
            	Toast.makeText(Launcher.this, "custom show", 0).show();
            }
            @Override
            public void onScrollProgressChanged(float progress) {
            }
            @Override
            public void onHide() {
            	Toast.makeText(Launcher.this, "custom hide", 0).show();
            }
        };
        addToCustomContentPage(customView, callbacks, "custom view");
	}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值