0

StaggeredGridLayoutManager を使用して 2 つの列を持つ RecyclerView を作成しました。すべてのアイテムには 2 つの画像とテキストが含まれています。最初の画像のサイズは (284*572 、840*401 または 283*232)、2 番目の 35*35 とテキスト、リスト見栄えは良いですが、問題は、ユーザーが下にスクロールしたときにスクロールがスムーズではなく、連続していないことです。画像はローカル ストレージ (描画可能) から取得されます。スクロール エクスペリエンスを承認するために何ができるでしょうか。

FantasyTabAdpter.java

public class FantasyTabAdapter extends RecyclerView.Adapter<FantasyTabAdapter.MyViewHolder> {
    private LayoutInflater inflater;
    private ArrayList<Fantasy> fantasies;

    public FantasyTabAdapter(Context context, ArrayList<Fantasy> fantasies) {
        inflater = LayoutInflater.from(context);
        this.fantasies = fantasies;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.fantasy_tab_item, parent, false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {
        final Fantasy fantasy = fantasies.get(position);
        holder.setData(fantasy, position);
    }

    @Override
    public int getItemCount() {
        return fantasies.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{
        ImageView fantasyImage;
        TextView fantasyTitle;
        ImageView fantasyStatus;

        public MyViewHolder(View itemView) {
            super(itemView);
            fantasyImage = (ImageView) itemView.findViewById(R.id.fantasy_tab_image);
            fantasyTitle = (TextView) itemView.findViewById(R.id.fantasy_tab_title);
            fantasyStatus = (ImageView) itemView.findViewById(R.id.fantasy_tab_status);
        }

        public void setData(Fantasy fantasy, int position) {
            this.fantasyTitle.setText(fantasy.getFantasyHeader());
            this.fantasyImage.setImageResource(fantasy.getFantasyHeaderImageID());
            this.fantasyStatus.setImageDrawable(fantasy.statusImagePlsgod);
        }
    }
}

フラグメントに RecyclerView を設定する

RecyclerView myRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view);

StaggeredGridLayoutManager setLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
FantasyTabAdapter fantasyTabAdapter = new FantasyTabAdapter(getActivity(),fantasies);

myRecyclerView.setLayoutManager(setLayoutManager);
myRecyclerView.setAdapter(fantasyTabAdapter);
4

1 に答える 1