@@ -0,0 +1,1862 @@
+package com.fresco.androidutil.widgt;%0A%0Aimport android.content.Context;%0Aimport android.support.v7.widget.RecyclerView;%0Aimport android.support.v7.widget.StaggeredGridLayoutManager;%0Aimport android.util.AttributeSet;%0Aimport android.view.View;%0A%0A/**%0A * Created by Ling.He on 15/11/11.%0A * %E8%87%AA%E9%80%82%E5%BA%94%E9%AB%98%E5%BA%A6%E7%9A%84StaggeredGridLayoutManager%EF%BC%8C%E7%94%A8%E4%BA%8ERecyclerView Wrap Content%E5%8A%9F%E8%83%BD: RecyclerView%E8%AE%BE%E7%BD%AEheight%E4%B8%BAwrap_content%E6%97%B6%EF%BC%8C%E4%B8%8D%E4%BC%9A%E6%A0%B9%E6%8D%AE%E5%86%85%E5%AE%B9%E8%AE%A1%E7%AE%97%E9%AB%98%E5%BA%A6%0A */%0Apublic class AdaptiveHeightStaggeredGridLayoutManager extends StaggeredGridLayoutManager %7B%0A%0A    private RecyclerView.Adapter mAdapter;%0A    public AdaptiveHeightStaggeredGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) %7B%0A        super(context, attrs, defStyleAttr, defStyleRes);%0A    %7D%0A%0A    public AdaptiveHeightStaggeredGridLayoutManager(int spanCount, int orientation) %7B%0A        super(spanCount, orientation);%0A    %7D%0A%0A    public void setAdapter(RecyclerView.Adapter adapter)%7B%0A        mAdapter = adapter;%0A    %7D%0A%0A    @Override%0A    public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) %7B%0A        try %7B%0A            View view = recycler.getViewForPosition(0);%0A            if (view != null && mAdapter != null ) %7B%0A                measureChild(view, widthSpec, heightSpec);%0A                int measuredWidth = View.MeasureSpec.getSize(widthSpec);%0A                int measuredHeight = view.getMeasuredHeight();%0A                //%E6%B1%82%E5%87%BA%E8%A1%8C%E6%95%B0%0A                int line = mAdapter.getItemCount() / getSpanCount();%0A                if (mAdapter.getItemCount() %25 getSpanCount() %3E 0) line++;%0A                setMeasuredDimension(measuredWidth, measuredHeight * line);%0A            %7D else %7B%0A                super.onMeasure(recycler, state, widthSpec, heightSpec);%0A            %7D%0A        %7D catch (Exception e) %7B%0A            super.onMeasure(recycler,state,widthSpec,heightSpec);%0A        %7D%0A    %7D%0A%7D%0A

add AdaptiveHeightStaggeredGridLayoutManager for RecyclerView