/**
* RecyclerView 高度自适应
*/
class MyLayoutManage extends LinearLayoutManager {
public MyLayoutManage(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
@Override
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) {
View view = recycler.getViewForPosition(0);
if(view != null){
measureChild(view, widthSpec, heightSpec);
int measuredWidth = View.MeasureSpec.getSize(widthSpec);
int measuredHeight = view.getMeasuredHeight();
setMeasuredDimension(measuredWidth, measuredHeight);
}
}
}
RecyclerView高度随Item自适应
最新推荐文章于 2024-08-11 03:43:59 发布