RecyclerView 在布局中显示指定的item数目

@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    View view = layoutInflater.inflate(R.layout.video_list_layout,viewGroup,false);
    MyHolder myHolder = new MyHolder(view);
    int parentHeight= viewGroup.getHeight();
    viewGroup.getWidth();
    ViewGroup.LayoutParams layoutParams = myHolder.itemView.getLayoutParams();
    layoutParams.height =  (parentHeight/ 3);//显示三条
    return myHolder;
}

你可能感兴趣的:(RecyclerView 在布局中显示指定的item数目)