Android Study

Flexbox + Recyclerview

85chong 2023. 8. 31. 14:09
728x90
반응형
SMALL

- 준비물 -

1. 준비된 Recyclerview , Adapter

(추후 작성 예정)

2. library

implementation 'com.google.android.flexbox:flexbox:3.0.0'

 

 

1. 준비된 RecyclerView 아래와 같이 세팅해 준다

<androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rcvMyList"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layoutManager="com.google.android.flexbox.FlexboxLayoutManager"/>

 

 

 

2. 클래스단 세팅

        ...
        val rcvMyList = findViewById<RecyclerView>(R.id.rcvMyList)

        rcvMyList.layoutManager = FlexboxLayoutManager(this).apply {
            flexWrap = FlexWrap.WRAP
            flexDirection = FlexDirection.ROW
            justifyContent = JustifyContent.FLEX_START
        }

        //myAdapter 는 준비된 사용하기
        rcvMyList.adapter = myAdapter
        ...

 

 

- 끝 -