国内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");
}