일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- onMeasure
- AppBarLayout
- recyclerview
- lifecycle
- 알고리즘
- LiveData
- HTTP
- BOJ
- 코틀린
- notification
- Android
- Algorithm
- CollapsingToolbarLayout
- onLayout
- hilt
- Behavior
- room
- 백준
- Coroutine
- sqlite
- CoordinatorLayout
- ViewModel
- 알림
- 안드로이드
- DataBinding
- View
- Navigation
- CustomView
- kotlin
- activity
- Today
- Total
목록ViewPager (3)
개발일지
CoordinatorLayout에서 ViewPager를 사용할 경우 이상하게 작동하는 경우가 있다. (ex : ViewPager가 짤린다.) AppBarLayout과 같이 사용시 @string/appbar_scrolling_view_behavior를 behavior로 설정하자. => @string/appbar_scrolling_view_behavior는 Scroll이 가능한 View에 설정해야한다. (NestedScrollView, RecyclerView)
Fragment에서 ViewPagerAdapter를 Fragment 맴버 변수로 선언한 경우 navigation시 오류 발생 => onCreateView에 ViewPagerAdapter를 생성해서 사용하자
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/PDt6F/btqUpaNZqWt/1G9B7isQqmpD6Q7qKfpUeK/img.gif)
SnapHelper RecyclerView를 ViewPager처럼 사용하거나 NumberPicker처럼 Scroll하다가 하나의 Item을 자석처럼 끌어당겨 하나의 Item을 선택하게 도와주는 클래스이다. Kotlin val snapHelper = LinearSnapHelper() snapHelper.attachToRecyclerView(recyclerView) OnScrollListener를 사용해서 SnapHelper가 선택한 position 받기 recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { var currentPosition = RecyclerView.NO_POSITION override fun onScrol..