Open
Description
hello, I found a problem while learning your code. see the usage below:
then, you add "Empty View" into the parent of mListView
(see EmptyLayout.java:463)
You view looks like this:
Obviously, I want the picture in center of list view instead of its parent.
Now I make a little change at EmptyLayout.java:changeEmptyType()
, you can easily understand.
~~~
// insert views in the root view
if (!mViewsAdded) {
RelativeLayout.LayoutParams lp = new LayoutParams(mListView.getWidth(), mListView.getHeight());
lp.topMargin = mListView.getTop();
lp.leftMargin = mListView.getLeft();
RelativeLayout rl = new RelativeLayout(mContext);
rl.setLayoutParams(lp);
if (mEmptyView!=null) {
rl.addView(mEmptyView);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mEmptyView.getLayoutParams();
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mEmptyView.setLayoutParams(layoutParams);
}
if (mLoadingView!=null) {
rl.addView(mLoadingView);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mLoadingView.getLayoutParams();
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mLoadingView.setLayoutParams(layoutParams);
}
if (mErrorView!=null) {
rl.addView(mErrorView);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mErrorView.getLayoutParams();
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mErrorView.setLayoutParams(layoutParams);
}
mViewsAdded = true;
ViewGroup parent = (ViewGroup) mListView.getParent();
parent.addView(rl);
mListView.setEmptyView(rl);
}
~~~
Thanks for your good code.
Metadata
Metadata
Assignees
Labels
No labels