ViewPager를 몰랐던 나
음~ RecyclerView로 어떻게 할 수 있겠다!
실패
음~ ViewFlipper라는 게 있대!
실패
돌고 돌아 ViewPager2로 원하는 기능 구현에 성공했다
이게 뭐라고 너무 돌아왔다
너무 잘 나와있는 블로그글을 찾아서 도움이 많이 되었다. 해당 글 링크는 맨 아래 참고란에 적어두겠다.
해당 글 내용 중 내가 원하는 기능에 대한 내용만 올린다.
구현하고 싶은 것
기존 서비스들에서 흔히 볼 수 있는 홍보 배너를 만들고 싶었다.
- 항목을 한 개씩 보여줌
- 사용자의 클릭이 없을 땐 자동 스크롤
- 사용자가 드래그하면 드래그하는 대로 이동
- 마지막 항목 다음에는 맨 처음 항목이 나올 것 (무한 스크롤)
- 클릭하면 관련 화면으로 이동
필요한 것들
- HomeFragment.kt 와 fragment_home.xml : 배너를 띄울 화면(액티비티 가능)
- HomeBannerAdapter.kt : RecyclerView의 어댑터처럼 배너 안에 들어갈 내용들을 연결해줌
- item_home_banner.xml : 배너에 들어갈 항목(아이템) 뷰 틀
- ModelImageOnly.kt : 배너의 각 아이템에 대한 데이터 틀
HomeFragment.kt 에 들어가는 자동스크롤과 무한 스크롤 내용을 제외하면
다른 파일 내용은 RecyclerView와 거의 똑같다
코드를 보자.
fragment_home.xml
...
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vpHomeBanner"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@+id/tvSignUpTitle"/>
...
배너 부분만 가져왔다.
ViewPager와 ViewPager2는 다른 것이니 헷갈리지 않도록 주의
HomeFragment.kt
이 내용이 기능의 핵심이다. 복잡할 수 있다.
맨 아래 참고에 있는 블로그글을 많이 참고했다.
나도 처음 써보는 것들이 많아서 불필요한 부분이 있을 수도 있다. 작동은 잘 됨
dummyImageUrl들은 구글에서 아무 이미지 주소나 가져온거라.. 아무거나 써도 된다
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.Message
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.example.duksunggoodsplatform_2021_android.databinding.FragmentHomeBinding
class HomeFragment : Fragment() {
private var _binding: FragmentHomeBinding? = null
private val binding get() = _binding!!
// 인덱스값이 아이템 수의 절반, 딱 중간쯤에서 시작하도록 해 앞뒤 어디로 이동해도 무한대처럼 보이게 함
private var bannerPosition = Int.MAX_VALUE/2
// 내가 만든 핸들러
private var homeBannerHandler = HomeBannerHandler()
// 1.5 초 간격으로 배너 페이지 넘어감
private val intervalTime = 1500.toLong()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
_binding = FragmentHomeBinding.inflate(inflater, container, false)
val view = binding.root
//banner
val bannerList = arrayListOf<ModelImageOnly>()
val bannerAdapter = activity?.let { HomeBannerAdapter(bannerList, it) }
val dummyImageUrl = "https://bit.ly/3yAt3za"
val dummyImageUrl2 = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUSEhIWFRUXGBYYFxgYFhoeGxggGhcYFhcdFxkeHiggGB0mIBgYITEhKCkrLi4uGx8zODMsNygtLisBCgoKDg0OGxAQGy0mICYvLy0tLi4tLS0tLS0tLS0tLy0tLS0tLS0vLS0tLS0tLS8tLS0tLS0tLS0tLy0tLS0tLf/AABEIALQBGAMBIgACEQEDEQH/xAAcAAACAgMBAQAAAAAAAAAAAAAFBgAEAgMHAQj/xABCEAACAQIEAwcCAwUHAgYDAAABAhEAAwQSITEFQVEGEyIyYXGBkaEjQrEHFFLB0TNicoLC4fCishUWJEOz8TRTdP/EABoBAAIDAQEAAAAAAAAAAAAAAAMEAAECBQb/xAA5EQABAwIDBAoABAYCAwAAAAABAAIRAyEEEjFBUWFxBRMigZGhscHR8BQy4fEGFSMzQlJysiRDYv/aAAwDAQACEQMRAD8AfKlSvKKuQquLbSqPC8QLa4i8fysv0RO8P6mrOObSqGDAOGExFx7rEE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yy6q/rqbEPY7B9Hf5v9Esfw3h+EZm7thdyDnX8ctgJQdnTVOkkP8Aid+6twdlI7vL810nSzR7tNJ+Lv8ACxzuPZ/5MRJrorq/tzepjcO4o97qaKaNg1oa31AA+pXoIZXEaq9huAsbs2lfZwti2UcNOKs2V8Ri6Mn3I2RksJtdGtPUrWHDmKXsDFZ4TKTqpmUEsuv86la/sTOiYwjOinhswc0ZQYOikGrV9mb0TEI6LLIYuZliPW6TyHotTux0RkCyymFzL7k3al3J6LSyhVsXihGWgj3s2pIaPCLOp59B5HopsLlfuCj2cqv/APvRlwppLT+bnplvwjXdw+vlcxxuPM5rmkEOcNPFeVxaTfLUfVLEHb2ZHsy6YHGsmGaO6HUEKzSmwLaEIUgEIQgBCEIAQhCAEIQgBcMTho5BUjA4f2haEKGk1Zkptaow+KdlMDI0l2H2/qwcx8gBr8l874p2SxD8S1mFjdhoS5o8RdmLqJ94bjLd5dANLJ0TQqtSjBPRW/tL6ipOVTWbb82dIP6KrcS9woNyvP8AWHMHh9HUG9d+a1cD/Rlh3ABxOXegTvz/AEQhZwoRe9+fPxM6decFaOhqRf0b4VvN5b/DncB9Fs4Lsph4RljaGjoAhCzVGCexnPE1ZLvSbL8fCowrDcIwckIWdkkartnQRgclKkIWVjEEIQgBBQhAJNJCgCRaEIBWolyEIDi6Mm/xHD0y6fRQMJ0/Edp/d119EIQCMB/rH/8AZ/8AP80juTr+I7Wv4dK57c0IUg6RtI3cT61+gUkIUA//2Q=="
//더미데이터 5개 - 무한스크롤 구현하다보니 데이터 리스트의 맨 첫번째 데이터가 맨 처음 보여지는 건 아님
bannerList.add(ModelImageOnly(dummyImageUrl))
bannerList.add(ModelImageOnly(dummyImageUrl2))
bannerList.add(ModelImageOnly(dummyImageUrl3))
bannerList.add(ModelImageOnly(dummyImageUrl2))
bannerList.add(ModelImageOnly(dummyImageUrl3))
bannerAdapter?.notifyDataSetChanged()
binding.vpHomeBanner.orientation = ViewPager2.ORIENTATION_HORIZONTAL
binding.vpHomeBanner.adapter = bannerAdapter
binding.vpHomeBanner.setCurrentItem(bannerPosition, false) //시작 위치 지정
binding.vpHomeBanner.apply {
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
//이 메서드의 state 값으로 뷰페이저의 상태를 알 수 있음
override fun onPageScrollStateChanged(state: Int) {
super.onPageScrollStateChanged(state)
when (state) {
//뷰페이저가 움직이는 중일 때 자동 스크롤 시작 함수 호출
ViewPager2.SCROLL_STATE_DRAGGING -> autoScrollStop()
//뷰페이저에서 손 뗐을 때, 뷰페이저가 멈춰있을 때 자동 스크롤 멈춤 함수 호출
ViewPager2.SCROLL_STATE_IDLE -> autoScrollStart(intervalTime)
}
}
})
}
return view
}//onCreate 끝
//배너 자동 스크롤 시작하게 하는 함수
private fun autoScrollStart(intervalTime: Long){
homeBannerHandler.removeMessages(0) //이거 안하면 핸들러가 여러개로 계속 늘어남
homeBannerHandler.sendEmptyMessageDelayed(0, intervalTime) //intervalTime만큼 반복해서 핸들러를 실행
}
//배너 자동 스크롤 멈추게 하는 함수
private fun autoScrollStop(){
homeBannerHandler.removeMessages(0) //핸들러 중지
}
//배너 자동 스크롤 컨트롤하는 클래스
private inner class HomeBannerHandler: Handler(Looper.getMainLooper()) {
override fun handleMessage(msg: Message) {
super.handleMessage(msg)
if(msg.what == 0){
binding.vpHomeBanner.setCurrentItem(++bannerPosition, true) //다음 페이지로 이동
autoScrollStart(intervalTime) //스크롤 킵고잉
}
}
}
//다른 화면으로 갔다가 돌아오면 배너 스크롤 다시 시작
override fun onResume() {
super.onResume()
autoScrollStart(intervalTime)
}
//다른 화면을 보고 있는 동안에는 배너 스크롤 안함
override fun onPause() {
super.onPause()
autoScrollStop()
}
}
뷰바인딩을 썼는데 쓰기 싫으면 binding.id값 대신 자기 방식대로 findViewById하던지 바로 id값으로 접근하던지 하면 된다.
전체적으로 RecyclerView와 사용법이 비슷하고, 달라진 것들은 ViewPager의 상태에 따라 다른 작동을 하도록 만들기 위해 쓰여진 코드들이다. 자동스크롤, 무한스크롤 기능과 관련된 것들.
HomeBannerAdapter.kt
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.example.패키지명.DetailActivity
import com.example.패키지명.R
class HomeBannerAdapter(private val imageList: ArrayList<ModelImageOnly>, private val mContext: Context): RecyclerView.Adapter<HomeBannerAdapter.CustomViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeBannerAdapter.CustomViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_home_banner, parent, false)
return CustomViewHolder(view).apply {
itemView.setOnClickListener {
val curPosition = bindingAdapterPosition
//val img: ModelImageOnly = imageList[curPosition]
// 클릭 시 관련 페이지로 이동하기
Toast.makeText(mContext, "${curPosition%5}번째 배너 클릭됨", Toast.LENGTH_SHORT).show()
val intent = Intent(mContext, DetailActivity::class.java)
mContext.startActivity(intent)
}
}
}
override fun onBindViewHolder(holder: HomeBannerAdapter.CustomViewHolder, position: Int) {
// 아이템 수로 굉장히 큰 수를 줬으므로 position으로 어떤 수가 나오든 5로 나눈 나머지 값 순서의의 데이터를 사해 5단위로 데이터가 반복되도록 한다.
// 다른 곳에서도 position값은 5로 나눈 나머지를 사용하면 된다.
Glide.with(mContext).load(imageList[position%5].img).into(holder.img)
}
override fun getItemCount(): Int {
return Int.MAX_VALUE // 뷰페이저 전환이 무한"처럼" 보이도록 굉장히 큰 억단위 수를 아이템 수로 임의로 넣어줌
}
class CustomViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val img: ImageView = itemView.findViewById(R.id.ivHomeBanner)
}
}
정말 무한 반복으로 스크롤 되도록 구현한 것은 아니다.
position에 엄청나게 큰 값을 줘서(억 단위) 무한대로 돌아가는 것처럼 보이게 만든 것이다.
비효율적인 면이 없지 않지만 다른 방법을 아직 못찾았다.
item_home_banner.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ivHomeBanner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</androidx.constraintlayout.widget.ConstraintLayout>
ModelImageOnly.kt
data class ModelImageOnly(
val img: String
)
완성
참고
1편 : https://todaycode.tistory.com/26?category=979455
2편 : https://todaycode.tistory.com/27
ViewPager2의 사용에 대해서 설명과 정리가 굉장히 잘 되어있는 글이다.
왠만큼 쓰이는 것들은 모두 설명되어있는 것 같다.
앞으로도 ViewPager2쓸 때 자주 참고할 예정
작성자님 감사합니다.
'Android > Kotlin' 카테고리의 다른 글
[Android/Kotlin] 뷰바인딩 클래스 빨간줄 오류 뜰 때 unresolved reference databinding (0) | 2022.03.03 |
---|---|
[Android/Kotlin] EditText 내용 비어있는지 빈 칸 확인하기 null check (0) | 2021.08.14 |
메모) RecyclerView GridLayout 아이템 간 간격, 크기 조정 (0) | 2021.08.08 |
[Android/Kotlin] 하단 네비게이션 바 BottomNavigation 만들기, 프래그먼트 상태 유지 (0) | 2021.08.08 |
[Android/Kotlin] RecyclerView등의 Adapter어댑터에서 액티비티 종료하기, setResult하기 (0) | 2021.07.29 |