原来以为这Launcher的左边实现一个自定义的内容会很复杂。看完launcher的代码后才发现,原来launcher已经帮我们做好了。
只需要两步
第一步重写下面的方法,设置为true
/** To be overriden by subclasses to hint to Launcher that we have custom content */
protected boolean hasCustomContentToLeft() {
return true;
}
第二步,
重写populateCustomContentContainer方法,在里面调用addToCustomContentPage,把你的View加入即可。
/**
* To be overridden by subclasses to populate the custom content container and call
* {@link #addToCustomContentPage}. This will only be invoked if
* {@link #hasCustomContentToLeft()} is {@code true}.
*/
protected void populateCustomContentContainer() {
if (hasCustomContentToLeft()) {
mLScreen = LScreenFactory.generatorScreen(this);
// CellLayout mieScreen = mWorkspace