Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 웹뷰
- 코틀린
- compose
- 의존성주입
- RecyclerView
- 코루틴
- 에러
- build
- Kotlin
- Android
- Github
- WebView
- Gradle
- error
- 안드로이드 스튜디오
- hilt
- cursor
- 깃헙
- 스튜디오
- studio
- DAGGER
- ADB
- coroutine
- 안드로이드스튜디오
- MVVM
- DI
- 유튜브
- 안스
- 안드로이드
- Retrofit
Archives
- Today
- Total
코딩하는 일용직 노동자
Pages must fill the whole ViewPager2 (use match_parent) 에러 해결사례 본문
ViewPager2 를 사용하던중 아래와 같은 에러가 발생했습니다.

java.lang.IllegalStateException: Pages must fill the whole ViewPager2 (use match_parent)
at androidx.viewpager2.widget.ViewPager2$4.onChildViewAttachedToWindow(ViewPager2.java:270)
at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:7561)
at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:860)
at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
발생한 에러메세지를 이용해 검색을 해보니 ViewPager2 클래스의
onChildViewAttachedToWindow() 메소드에서 width 나 height 가 wrap_content 라면 익셉션을 발생시키는것이었습니다.

제가 작업중인 소스에서 살펴보니 ViewPager에서 사용하는 item xml 파일에
android:layout_width="wrap_content"
이런 처리때문에 발생한 오류입니다.
android:layout_width="match_parent"
로 처리하니 간단히 해결되었습니다.
'안드로이드' 카테고리의 다른 글
| Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. (0) | 2022.07.07 |
|---|---|
| WebView를 사용한 고용량 이미지 표시 사례. (0) | 2022.05.27 |
| Invoke-customs are only supported starting with Android O (--min-api 26) 에러 수정하기 (0) | 2022.04.20 |
| 모바일용 FFmpeg 라이브러리 (0) | 2022.04.20 |
| 네트워크 Response 처리 라이브러리 (0) | 2022.04.19 |