NOW OR NEVER

[Android] ViewPager2 Fragment 안보이는 Error 본문

Android

[Android] ViewPager2 Fragment 안보이는 Error

LAURA 2023. 7. 27. 00:09
반응형
<androidx.viewpager2.widget.ViewPager2
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tabLayout" />
  •  viewPage에 계속 지정한 fragment가 안보이길래 뭐가 문제인가 했더니.... layout width랑 layout_height가 0으로 하고 constraint 값으로 크기를 지정하려 하였으나 이것이 문제인 듯하여 싹 다 지워버리고 아래 코드처럼 짰더니 잘 나온다. 
<androidx.viewpager2.widget.ViewPager2
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

 

 

Comments