[Android] RecyclerView 의 scrollToPosition 하단(오른쪽)기준으로 변경하기 RecyclerView의 scroll position을 이동시키고 싶은 경우 recycler_view.scrollToPosition(20) 또는 layoutManager.scrollToPosition(20) 을 이용하여 이동시키게 되지만 이는 상단기준으로 20번째 아이템으로 이동하게 된다. (아래 이미지는 position: 0이 text가 1인 아이템) 이것을 하단기준의 20번째 아이템으로 이동시키고 싶은 경우 val smoothScroller = object : LinearSmoothScroller(this) { override fun getVerticalSnapPreference(): Int { return LinearSmoothScroller.SNAP_TO_END } } smoothScroller... 모바일 프로그래밍/안드로이드 5년 전
RecyclerView의 scrollToPosition나 smoothScrollToPosition 사용 시 Item사이의 margin이 있는 경우 RecyclerView의 scrollToPosition나 smoothScrollToPosition 을 사용할 경우 각각의 Item 사이의 margin이 존재하여 정확한 위치에 스크롤 되지 않고 Margin만큼 벌어져서 보여지게 되는 경우가 있다. val smoothScroller = object : LinearSmoothScroller(context) { override fun getHorizontalSnapPreference(): Int { return LinearSmoothScroller.SNAP_TO_END } } smoothScroller.targetPosition = nextPosition layoutManager.startSmoothScroll(smoothScroller) 수평, 수직 형태의 .. 모바일 프로그래밍/안드로이드 6년 전