search

Home  >  Q&A  >  body text

android-ui - Android上边有一些布局,下边是listview的页面,有什么好的实现方法吗?(有图)

就是许多应用常见的首页列表。

上半部分有各种布局,下半部分是一个可以加载更多的列表。

类似下图这两种。

以前用addheaderview去实现,或者干脆直接给listview(recyclerView)使用不同的item。但感觉都不是很好。有什么比较优雅的解决办法吗?

用CoordinatorLayout会比较好吗?

高洛峰高洛峰2773 days ago453

reply all(4)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 18:00:27

    Use recyclerview and use different itemtypes

    reply
    0
  • 巴扎黑

    巴扎黑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?

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 18:00:27

    You can refer to the blog http://blog.csdn.net/github_3...

    reply
    0
  • 阿神

    阿神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);
        }
    
    }

    reply
    0
  • Cancelreply