Battle of GridLayout with RecyclerView

Battle of GridLayout with RecyclerView

GridLayout with RecyclerView

Kazuki Chigita

March 26, 2019

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

38 slides
  1. pulic class GridLayout extends ViewGroup 0 1 2 … ⼦Viewはなんの指定もしなければ

    各領域に広がる N+1本の線でN個の等分領域に分けられる جૅ
  2. ͜ΜͳLayoutΛ͘Έ͍ͨ1 spanCount=4のGridLayoutManagerをセットする GridLayoutManager.SpanSizeLookUp() { override fun getSpanSize(position: Int): Int {

    //positionに応じて割り当てるサイズを渡す. return when { position == 0 -> 4 position <= 2 -> 2 else -> 1 } } }
  3. ͜ΜͳLayoutΛ͘Έ͍ͨ1 spanCount=4のGridLayoutManagerをセットする GridLayoutManager.SpanSizeLookUp() { override fun getSpanSize(position: Int): Int {

    //positionに応じて割り当てるサイズを渡す. return when { position == 0 -> 4 position <= 2 -> 2 else -> 1 } } } RecyclerViewのItemDecorationのうちgetItemOffestsをoverride
  4. ͜ΜͳLayoutΛ͘Έ͍ͨ1 spanCount=4のGridLayoutManagerをセットする GridLayoutManager.SpanSizeLookUp() { override fun getSpanSize(position: Int): Int {

    //positionに応じて割り当てるサイズを渡す. return when { position == 0 -> 4 position <= 2 -> 2 else -> 1 } } } RecyclerView. ItemDecoration() { override fun getItemOffests( outRect: Rect, view: View, parent: RecyclerView, state: RecylerView.State ) { outRect.left = margin ... } }

More Decks by Kazuki Chigita

Other Decks in Technology