Skip to content

Latest commit

ย 

History

History
386 lines (295 loc) ยท 13.9 KB

Recyclerview_sieun.md

File metadata and controls

386 lines (295 loc) ยท 13.9 KB

0.์ฐธ๊ณ ๋ฌธ์„œ

https://developer.android.com/reference/android/support/v7/widget/RecyclerView

http://liveonthekeyboard.tistory.com/135

http://www.kmshack.kr/2014/10/android-recyclerview/

[๋ฃจ๋น„ํŽ˜์ดํผ] ๋  ๋•Œ๊นŒ์ง€ ์•ˆ๋“œ๋กœ์ด๋“œ (์˜ค์ค€์„)

1.Recyclerview

1.1. ์†Œ๊ฐœ

  • ๊ธฐ์กด์˜ ListView๋Š” ์ปค์Šคํ…€ํ•˜๊ธฐ์—๋Š” ๊ตฌ์กฐ์ ์ธ ๋ฌธ์ œ๋กœ ๋งŽ์€ ์ œ์•ฝ์ด ๋”ฐ๋ž์œผ๋ฉฐ, ๊ตฌ์กฐ์ ์ธ ๋ฌธ์ œ๋กœ ์ธํ•ด ์„ฑ๋Šฅ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ด ๋ฌธ์ œ๋“ค์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์ข€ ๋” ๋‹ค์–‘ํ•œ ํ˜•ํƒœ๋กœ ๊ฐœ๋ฐœ์ž๊ฐ€ ์ปค์Šคํ…€ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“ค์–ด์ง„ ๊ฒƒ์ด RecyclerView!

  • ๊ธฐ์กด์˜ ListView๋ณด๋‹ค ์œ ์—ฐํ•˜๊ณ  ์„ฑ๋Šฅ์ด ํ–ฅ์ƒ๋œ ๊ณ ๊ธ‰ ์œ„์ ฏ

  • ๋ฆฌ์ŠคํŠธ๋ฅผ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•œ ์–ด๋Œ‘ํ„ฐ๋ทฐ๋ฅผ ์ข€ ๋” ๊ฐœ์„ ํ•œ ์ปดํฌ๋„ŒํŠธ

  • ํฐ ํ‹€์€ ์œ ์ง€ํ•œ ์ฑ„ ๋ฐ์ดํ„ฐ๋งŒ ๋ฐ”๋€œ

  1. ์–ด๋Œ‘ํ„ฐ๋ทฐ์™€์˜ ์ฐจ์ด์ 
    1. RecyclerView๋Š” ๋ ˆ์ด์•„์›ƒ ๋งค๋‹ˆ์ €(LayoutManager)๋ฅผ ์ง€์ •ํ•ด ์ค˜์•ผ ํ•จ
    2. ์–ด๋Œ‘ํ„ฐ๋ทฐ์—์„œ๋Š” ์„ ํƒ์‚ฌํ•ญ์ด์—ˆ๋˜ ๋ทฐํ™€๋” ํŒจ๋˜์ด RecyclerView์—์„œ๋Š” ๊ผญ ๊ตฌํ˜„ํ•ด์•ผ ํ•จ
    3. ์–ด๋Œ‘ํ„ฐ๋ทฐ๋Š” ๋ฏธ๋ฆฌ ์ œ๊ณต๋œ ์–ด๋Œ‘ํ„ฐ๊ฐ€ ์žˆ๋Š” ๋ฐ˜๋ฉด RecyclerView์˜ ์–ด๋Œ‘ํ„ฐ๋Š” ์•„๋ฌด๊ฒƒ๋„ ์ œ๊ณตํ•ด ์ฃผ์ง€ ์•Š์Œ
  2. ์žฅ์ 
    1. ViewHolderํŒจํ„ด์„ ์ ์šฉํ•˜์—ฌ ๋ทฐ๋ฅผ ์žฌํ™œ์šฉ
    2. Swipe๋ฅผ ์ด์šฉํ•˜์—ฌ ์ง๊ด€์ ์ธ Refresh UI๊ตฌ์กฐ ์„ค๊ณ„๊ฐ€๋Šฅ
    3. position์— ๋”ฐ๋ผ์„œ ํ•œ ๋ฆฌ์ŠคํŠธ ๋‚ด์—์„œ ๋‹ค์–‘ํ•œ ๋ทฐ๋ฅผ ํ‘œํ˜„๊ฐ€๋Šฅ(MultiView)
  3. ๋‹จ์ 
    1. ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ์™€ ์ปค์„œ(Cursor)๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์Œ

1.2. ์ฃผ์š” ํด๋ž˜์Šค

  • RecyclerView.Adapter
    ์–ด๋Œ‘ํ„ฐ๋ทฐ์˜ ์–ด๋Œ‘ํ„ฐ์™€ ๊ฐ™์€ ์—ญํ• 
  • RecyclerView.ViewHolder
    ๋ทฐํ™€๋” ํด๋ž˜์Šค๋Š” ์ด๊ฒƒ์„ ์ƒ์†ํ•ด์•ผํ•จ
  • LayoutManager
    ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐฐ์น˜ํ•˜๊ณ , ๋ทฐ์˜ ์žฌ์‚ฌ์šฉ ๋“ฑ์„ ๊ฒฐ์ •ํ•˜๋Š” ์—ญํ• ์„ ํ•˜์—ฌ ๊ธฐ์กด์˜ ์–ด๋Œ‘ํ„ฐ๋ทฐ๋ณด๋‹ค ์„ฑ๋Šฅ์ด ๊ฐœ์„ ๋จ
    • LinearLayoutManager : ๋ฐ์ดํ„ฐ๋ฅผ ๋ฆฌ์ŠคํŠธ๋ทฐ์ฒ˜๋Ÿผ ์„ธ๋กœ๋‚˜ ๊ฐ€๋กœ ํ•œ ์ค„๋กœ ํ‘œ์‹œ

    • GridLayoutManager : ๊ทธ๋ฆฌ๋“œ๋ทฐ์ฒ˜๋Ÿผ ๋ฐ์ดํ„ฐ๋ฅผ ๊ทธ๋ฆฌ๋“œ ํ˜•์‹์œผ๋กœ ํ‘œ์‹œ

    • StaggeredGridLayoutManager : ๊ทธ๋ฆฌ๋“œ๋ทฐ์ฒ˜๋Ÿผ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฒฉ์ž ํ˜•์‹์œผ๋กœ ํ‘œ์‹œํ•˜๋ฉด์„œ ์•„์ดํ…œ์˜ ๋†’์ด๊ฐ€ ์ผ์ •ํ•˜์ง€ ์•Š์•„๋„ ๋˜๋Š” ์ง€๊ทธ์žฌ๊ทธํ˜• ๊ทธ๋ฆฌ๋“œ ํ˜•์‹์œผ๋กœ ํ‘œ์‹œ

  • RecyclerView.ItemAnimation
    ์•„์ดํ…œ์ด ์ถ”๊ฐ€, ์‚ญ์ œ ๋˜๋Š” ์žฌ์ •๋ ฌ๋  ๋•Œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ •์˜
  • RecyclerView.ItemDecoration
    ์•„์ดํ…œ์„ ์„ธ๋ถ€์ ์œผ๋กœ ๊พธ๋ฐˆ

1.3. ์˜ˆ์ œ

1.3.1.RecyclerView + CardView ์‚ฌ์šฉ
  1. ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ข…์†์„ฑ ์ถ”๊ฐ€

    dependencies{
        ...
    	implementation 'com.android.support:recyclerview-v7:26.1.0'
    	implementation 'com.android.support:cardview-v7:26.1.0'   
    }
  2. CardView ๋ ˆ์ด์•„์›ƒ ์ž‘์„ฑ

  3. ์–ด๋Œ‘ํ„ฐ ์ž‘์„ฑ

    • RecyclerView.Adapter๋ฅผ ์ƒ์†๋ฐ›์•„ ๊ตฌํ˜„ํ•ด์•ผ ํ•จ

    • ๋ถ€๋ถ„์—๋Š” RecyclerView.ViewHolder ํด๋ž˜์Šค๋ฅผ ์ƒ์†ํ•œ ๋ทฐํ™€๋” ์ง€์ •ํ•ด์•ผ ํ•จ

      => ListView์—์„œ๋Š” ๋ทฐํ™€๋” ํŒจํ„ด ์‚ฌ์šฉ์ด ๊ถŒ์žฅ์‚ฌํ•ญ์ด์—ˆ์œผ๋‚˜, RecyclerView๋Š” ์˜๋ฌด

    import android.support.v7.widget.RecyclerView;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.TextView;
    import java.util.List;
    
    public class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.ViewHolder>{
        private final List<CardItem> mDataList;
        public MyRecyclerAdapter(List<CardItem> dataList){
            mDataList = dataList;
        }
        // ๋ทฐ ํ™€๋”๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ถ€๋ถ„. ๋ ˆ์ด์•„์›ƒ์„ ๋งŒ๋“œ๋Š” ๋ถ€๋ถ„
        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.item_card, parent, false);
            return new ViewHolder(view);
        }
        // ๋ทฐ ํ™€๋”์— ๋ฐ์ดํ„ฐ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ถ€๋ถ„
        @Override
        public void onBindViewHolder(ViewHolder holder, int position) {
            // CardItem๋Š” ์•„์ดํ…œ์— ํ‘œ์‹œํ•  ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ง€๋Š” ๋ชจ๋ธ ํด๋ž˜์Šค
            CardItem item = mDataList.get(position);
            holder.title.setText(item.getTitle());
            holder.contents.setText(item.getContents());
        }
        //์•„์ดํ…œ์˜ ์ˆ˜
        @Override
        public int getItemCount() {
            return mDataList.size();
        }
        //๊ฐ๊ฐ์˜ ์•„์ดํ…œ์˜ ๋ ˆํผ๋Ÿฐ์Šค๋ฅผ ์ €์žฅํ•  ๋ทฐ ํ™€๋” ํด๋ž˜์Šค
        //๋ฐ˜๋“œ์‹œ RecyclerView.ViewHolder๋ฅผ ์ƒ์†ํ•ด์•ผ ํ•จ
        public static class ViewHolder extends RecyclerView.ViewHolder{
            TextView title;
            TextView contents;
    
            public ViewHolder(View itemview){
                super(itemview);
                title = itemview.findViewById(R.id.title_text);
                contents = itemview.findViewById(R.id.contents_text);
            }
        }
    }
  4. ๋ ˆ์ด์•„์›ƒ ๋งค๋‹ˆ์ €์™€ ์–ด๋Œ‘ํ„ฐ ์„ค์ • - LinearLayoutManager

    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.support.v7.widget.GridLayoutManager;
    import android.support.v7.widget.LinearLayoutManager;
    import android.support.v7.widget.RecyclerView;
    import android.support.v7.widget.StaggeredGridLayoutManager;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
            //๋ ˆ์ด์•„์›ƒ ๋งค๋‹ˆ์ €๋กœ LinearLayoutManager๋ฅผ ์„ค์ •
            RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
            recyclerView.setLayoutManager(layoutManager);
            //ํ‘œ์‹œํ•  ์ž„์‹œ ๋ฐ์ดํ„ฐ
            List<CardItem> dataList = new ArrayList<>();
            // dataList.add(new CardItem(title, contents));
            dataList.add(new CardItem("์ด๊ฒƒ์€ ์ฒซ๋ฒˆ์งธ ์•„์ดํ…œ", "์•ˆ๋“œ๋กœ์ด๋“œ ๋ณด์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค"));
            dataList.add(new CardItem("์ด๊ฒƒ์€ ๋‘๋ฒˆ์งธ ์•„์ดํ…œ", "๋‘ ์ค„ ์ž…๋ ฅ\n๋‘ ์ค„ ์ž…๋‹ˆ๋‹ค"));
            dataList.add(new CardItem("์ด๊ฒƒ์€ ์„ธ๋ฒˆ์งธ ์•„์ดํ…œ", "์„ธ์ค„\n๋‘๋ฒˆ์งธ ์ค„\n์„ธ๋ฒˆ์งธ ์ค„"));
            dataList.add(new CardItem("์ด๊ฒƒ์€ ๋„ค๋ฒˆ์งธ ์•„์ดํ…œ", "์ž˜ ๋˜๋„ค์š”!"));
            //์–ด๋Œ‘ํ„ฐ ์„ค์ •
            MyRecyclerAdapter adapter = new MyRecyclerAdapter(dataList);
            recyclerView.setAdapter(adapter);
        }
    }

    1530258033138

    • ๋ ˆ์ด์•„์›ƒ ๋งค๋‹ˆ์ € ์ฝ”๋“œ ์ •๋ฆฌ

      • LinearLayoutManager

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
      • GridLayoutManager

        GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
        gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(gridLayoutManager);
      • StaggeredGridLayoutManager

        StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2,
                 StaggeredGridLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(gridLayoutManager);
1.3.2.ํด๋ฆญ ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ
  1. RecyclerView ์•„์ดํ…œ์˜ ํด๋ฆญ ๋ฆฌ์Šค๋„ˆ๋ฅผ ์ œ๊ณตํ•˜์ง€ ์•Š๋Š”๋‹ค

    =>๋ชจ๋“  ์ด๋ฒคํŠธ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ๋ฅผ ๊ฐœ๋ฐœ์ž๊ฐ€ ์ง์ ‘ ๊ตฌํ˜„ํ•ด์•ผํ•จ

public class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.ViewHolder>{
    private final List<CardItem> mDataList;
    private MyRecyclerViewClickListener mListener;
    ... ์ƒ๋žต ...
    public void setOnClickListener(MyRecyclerViewClickListener listener){
        mListener = listener;
    }
    public interface MyRecyclerViewClickListener {
        // ์•„์ดํ…œ ์ „์ฒด ๋ถ€๋ถ„์˜ ํด๋ฆญ
        void onItemClicked(int position);
        // share ๋ฒ„ํŠผ ํด๋ฆญ
        void onShareButtonClicked(int position);
        // Learn More ๋ฒ„ํŠผ ํด๋ฆญ
        void onLearnMoreButtonClicked(int position);
    }
}
  1. onBindViewHolder() ๋ฉ”์„œ๋“œ์—์„œ ํด๋ฆญ์ด ๋ฐœ์ƒํ•˜๋Š” ๊ณณ์„ MyRecyclerViewClickListener์™€ ์—ฐ๊ฒฐ
public class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.ViewHolder> {
   ... ์ƒ๋žต ...
    // ๋ทฐ ํ™€๋”์— ๋ฐ์ดํ„ฐ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ถ€๋ถ„
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        CardItem item = mDataList.get(position);
        holder.title.setText(item.getTitle());
        holder.contents.setText(item.getContents());
        // ํด๋ฆญ ์ด๋ฒคํŠธ
        if (mListener != null) {
            // ํ˜„์žฌ ์œ„์น˜
            final int pos = position;
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    mListener.onItemClicked(pos);
                }
            });
            holder.share.setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View v) {
                    mListener.onShareButtonClicked(pos);
                }
            });
            holder.more.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mListener.onLearnMoreButtonClicked(pos);
                }
            });
        }
    }
    ... ์ƒ๋žต ...
    // ๊ฐ๊ฐ์˜ ์•„์ดํ…œ์˜ ๋ ˆํผ๋Ÿฐ์Šค๋ฅผ ์ €์žฅํ•  ๋ทฐ ํ™€๋” ํด๋ž˜์Šค
    // ๋ฐ˜๋“œ์‹œ RecyclerView.ViewHolder๋ฅผ ์ƒ์†ํ•ด์•ผ ํ•จ
    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView title;
        TextView contents;
        Button share;
        Button more;

        public ViewHolder(View itemview) {
            super(itemview);
            title = itemview.findViewById(R.id.title_text);
            contents = itemview.findViewById(R.id.contents_text);
            share = (Button) itemview.findViewById(R.id.share_button);
            more = (Button) itemview.findViewById(R.id.more_button);
        }
    }
	... ์ƒ๋žต ...
}
  1. ์•กํ‹ฐ๋น„ํ‹ฐ์—์„œ ๋ฆฌ์Šค๋„ˆ ๊ตฌํ˜„, ๋ฉ”์„œ๋“œ ์žฌ์ •์˜
public class MainActivity extends AppCompatActivity implements MyRecyclerAdapter.MyRecyclerViewClickListener{
    private static final String TAG = MainActivity.class.getSimpleName();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ... ์ƒ๋žต ...
        // ์–ด๋Œ‘ํ„ฐ ์„ค์ •
        MyRecyclerAdapter adapter = new MyRecyclerAdapter(dataList);
        adapter.setOnClickListener(this);
        recyclerView.setAdapter(adapter);
    }
    @Override
    public void onItemClicked(int position) {
        Log.d(TAG, "onItemClicked: " + position);
    }
    @Override
    public void onShareButtonClicked(int position) {
        Log.d(TAG, "onShareButtonClicked: " + position);
    }
    @Override
    public void onLearnMoreButtonClicked(int position) {
        Log.d(TAG, "onLearnMoreButtonClicked: " + position);
    }
}
  1. ์ฝœ๋ฐฑ์ด ์ž˜ ๋™์ž‘ํ•˜๋Š”์ง€ ํ™•์ธ
1.3.3. ์• ๋‹ˆ๋ฉ”์ด์…˜
  1. ์–ด๋Œ‘ํ„ฐ๋ทฐ์—์„œ๋Š” ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์„ ๋•Œ ์ด๋ฅผ ๋ฐ˜์˜ํ•˜๊ธฐ ์œ„ํ•ด notifyDataSetChanged() ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๋ฐ์ดํ„ฐ ๋ณ€๊ฒฝ์„ ํ†ต์ง€ํ•˜๊ณ  ๋ทฐ๊ฐ€ ์ƒ์‹ ๋˜๋„๋ก ํ•จ => ํ•ญ์ƒ ์ „์ฒด ํ•ญ๋ชฉ์„ ์ƒˆ๋กœ ๋กœ๋“œ

  2. RecyclerView์˜ ์–ด๋Œ‘ํ„ฐ๋Š” ๊ฐ ์ƒํ™ฉ์— ๋งž๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํ†ต์ง€ ๋ฉ”์„œ๋“œ ์ œ๊ณต

    • notifyItemInserted(int position) : position ์œ„์น˜์˜ ์•„์ดํ…œ์ด ์‚ฝ์ž…๋œ ๊ฒƒ์„ ํ†ต์ง€
    • notifyItemRemoved(int position) : position ์œ„์น˜์˜ ์•„์ดํ…œ์ด ์‚ญ์ œ๋œ ๊ฒƒ์„ ํ†ต์ง€
    public class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.ViewHolder> {
        ... ์ƒ๋žต ...
        public void removeItem(int position){
            mDataList.remove(position);
            notifyItemRemoved(position);
            notifyItemRangeChanged(position, mDataList.size());
        }
        public void addItem(int position, CardView item){
            mDataList.add(position, item);
            notifyItemInserted(position);
            notifyItemRangeChanged(position, mDataList.size());
        }
    }
    • ์œ„ ๋ฉ”์„œ๋“œ๋“ค์€ ์•„์ดํ…œ์ด ์ถ”๊ฐ€, ์‚ญ์ œ๋˜๋ฉด์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์ง€์›๋จ
    • notifyItemRangeChanged(position, mDataList.size()) ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด์•ผ ์ œ๋Œ€๋กœ ์ž‘๋™
      • ์ด ๋ฉ”์„œ๋“œ๋Š” ์ฒซ ๋ฒˆ์งธ ์ธ์ž๋ถ€ํ„ฐ ๋‘ ๋ฒˆ์งธ ์ธ์ž ์‚ฌ์ด์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Œ์„ ํ†ต์ง€
      • ์ด์— ๋งž๊ฒŒ ์ œ๋Œ€๋กœ ๋™์ž‘ํ•˜๋„๋ก ํ•จ
  3. ItemAnimator์™€ ItemDecoration

    1. RecyclerView๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ชจ์–‘์„ ๊พธ๋ฐ€ ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณต

      • ItemAnimator

        • ์•„์ดํ…œ์ด ์ถ”๊ฐ€, ์‚ญ์ œ, ์ •๋ ฌ๋  ๋•Œ์˜ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋Š” ํด๋ž˜์Šค
        • ์ด ํด๋ž˜์Šค๋ฅผ ์ƒ์†ํ•˜๋ฉด ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์ถ”์ƒ ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜์—ฌ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ตฌ์„ฑ ๊ฐ€๋Šฅ
      • ItemDecoration

        • ์•„์ดํ…œ์˜ ๋ชจ์–‘์„ ๊พธ๋ฐ€ ์ˆ˜ ์žˆ๋Š” ํด๋ž˜์Šค

          DividerItemDecoration decoration = new DividerItemDecoration(this, layoutManager.getOrientation());
          recyclerView.addItemDecoration(decoration);
      • DefaultItemAnimator

        • RecyclerView๋Š” ํŠน๋ณ„ํ•œ ์„ค์ •์ด ์—†์œผ๋ฉด ๋ฏธ๋ฆฌ์ •์˜๋œ DefaultItemAnimator๊ฐ€ ์ ์šฉ๋จ

        • ์ด ํด๋ž˜์Šค๋Š” ์ถ”๊ฐ€, ์‚ญ์ œ, ์ •๋ ฌ ์• ๋‹ˆ๋ฉ”์ด์…˜์˜ ์‹คํ–‰ ์†๋„๋ฅผ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ์Œ

          DefaultItemAnimator animator = new DefaultItemAnimator();
          animator.setAddDuration(1000);
          animator.setremoveDuration(1000);
          animator.setMoveDuration(1000);
          animator.setChangeDuration(1000);
          recyclerView.setItemAnimator(animator);