当前位置:网站首页>The horizontally scrolling recycleview displays five and a half on one screen, lower than the average distribution of five

The horizontally scrolling recycleview displays five and a half on one screen, lower than the average distribution of five

2022-07-05 10:11:00 A bird carved in the desert

    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = mInflater.inflate(R.layout.layout_item_hq_cn_icon, parent, false);

        int columnWidth;
        if (mDataSet.size() > 5) {
            columnWidth = (int) (parent.getMeasuredWidth() / 5.57f);
        } else {
            columnWidth = (int) (parent.getMeasuredWidth() / mDataSet.size());
        }

        RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(columnWidth, RecyclerView.LayoutParams.WRAP_CONTENT);
        itemView.setLayoutParams(lp);
        return ViewHolder.createViewHolder(mContext, itemView);
    }

原网站

版权声明
本文为[A bird carved in the desert]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050941163334.html