就是许多应用常见的首页列表。
上半部分有各种布局,下半部分是一个可以加载更多的列表。
类似下图这两种。
以前用addheaderview去实现,或者干脆直接给listview(recyclerView)使用不同的item。但感觉都不是很好。有什么比较优雅的解决办法吗?
用CoordinatorLayout会比较好吗?
巴扎黑2017-04-17 18:00:27
Why do you think it is a listView with a header added, rather than a combination of multiple listViews?
阿神2017-04-17 18:00:27
PullToRefreshScrollView, and then put a custom ListView inside, which can be pulled up to refresh and pulled down to load.
Of course you can also set a custom GridView.
/**
* 重写 onMeasure
* 解决:listView在滚动布局,只显示了一行的问题
*/
public class NoScrollListView extends ListView {
public NoScrollListView(Context context) {
super(context);
}
public NoScrollListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NoScrollListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}