Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Battle of GridLayout with RecyclerView

Battle of GridLayout with RecyclerView

GridLayout with RecyclerView

Kazuki Chigita

March 26, 2019
Tweet

More Decks by Kazuki Chigita

Other Decks in Technology

Transcript

  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 ... } }