일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- Coroutine
- 알고리즘
- 안드로이드
- sqlite
- LiveData
- CollapsingToolbarLayout
- BOJ
- 알림
- Algorithm
- HTTP
- hilt
- CoordinatorLayout
- lifecycle
- Navigation
- Android
- activity
- ViewModel
- room
- View
- notification
- kotlin
- DataBinding
- onLayout
- recyclerview
- 백준
- CustomView
- AppBarLayout
- Behavior
- onMeasure
- 코틀린
- Today
- Total
목록여백 (2)
개발일지
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/tTrB0/btqUcAmHMn5/wPPELFOZ8IKCTtADK2uYCK/img.png)
StaggeredGridLayoutManager를 이용한 RecyclerView에서 ViewHolder에 Margin을 설정하면 배치가 이상해지는 오류가 발생했다. => gapStrategy를 설정하자 with(binding.recyclerView) { adapter = MovieAdapter() addItemDecoration(GridSpacingItemDecoration(2, 5.toDp())) layoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL).apply { gapStrategy = StaggeredGridLayoutManager.GAP_HANDLING_NONE } }
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bz9CvE/btqS9YIqEjU/xX4jwtvi3xutNufaw7kLw0/img.png)
ItemDecoration RecyclerView의 ViewHolder를 꾸미는 역할을 한다. ViewHolder간의 동일한 여백을 주거나, 구분선을 넣기, RecyclerView Background 이미지 주기 등 다양한 효과를 줄 수 있다. GridSpacingItemDecoration 여백을 주는 ItemDecoration이다. class GridSpacingItemDecoration(private val spanCount: Int, private val spacing: Int, private val includeEdge: Boolean = true) : RecyclerView.ItemDecoration() { override fun getItemOffsets(outRect: Rect, view: ..