I have a kotlin app. I don't understand why my recyclerView is invisible. When I change ScrollView to ConstraintLayout everything works fine, but it isn't scrollable. I wanted to make my fragment scrollable. I tried NestedScrollView. I don't have any ideas. Here's my ScrollView:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ui.fragments.ChannelFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/channelBlock"
android:layout_width="match_parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_margin="30dp"
android:background="@drawable/main_background"
android:padding="20dp"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivChannelImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/ic_person_flat"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/channelName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Qewbite"
android:textColor="@color/whiteColor"
android:layout_marginTop="8dp"
android:textSize="26sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivChannelImage" />
<LinearLayout
android:id="@+id/subscriptionBlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/channelName"
android:gravity="center_vertical">
<Button
android:id="@+id/subscribeButton"
android:layout_width="wrap_content"
android:textAllCaps="false"
android:layout_height="40dp"
android:textSize="12dp"
android:gravity="center"
android:background="@drawable/subscribed_background"
android:padding="0dp"
app:backgroundTint="@color/colorDark"
android:textColor="@color/whiteColor"
android:layout_marginLeft="5dp"
android:text="Unfollow" />
<ImageButton
android:id="@+id/notificationButton"
android:layout_width="40dp"
android:textAllCaps="false"
android:layout_height="40dp"
android:textSize="12dp"
android:tint="@color/whiteColor"
android:src="@drawable/ic_notification"
app:backgroundTint="@color/colorDark"
android:background="@drawable/subscribe_notification_background"
android:padding="0dp"
android:textColor="@color/whiteColor" />
</LinearLayout>
<View
android:id="@+id/headerHr"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorNavbarGray"
app:layout_constraintTop_toBottomOf="@id/subscriptionBlock"
android:layout_marginTop="10dp"
/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/channelSubscribers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10M"
android:textColor="@color/whiteColor"
android:layout_marginTop="8dp"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@id/channelSubscribersTitle"
app:layout_constraintEnd_toEndOf="@id/channelSubscribersTitle"
app:layout_constraintTop_toBottomOf="@id/headerHr" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/channelSubscribersTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Followers"
android:textColor="@color/colorLightGray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/channelSubscribers" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/channelListened"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="120M"
android:textColor="@color/whiteColor"
android:layout_marginTop="8dp"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@id/channelListenedTitle"
app:layout_constraintEnd_toEndOf="@id/channelListenedTitle"
app:layout_constraintTop_toBottomOf="@id/headerHr" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/channelListenedTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Auditions"
android:textColor="@color/colorLightGray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/channelListened" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/channelYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021"
android:textColor="@color/whiteColor"
android:layout_marginTop="8dp"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/headerHr" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/channelYearTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Year"
android:textColor="@color/colorLightGray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="@id/channelYear"
app:layout_constraintEnd_toEndOf="@id/channelYear"
app:layout_constraintTop_toBottomOf="@id/channelSubscribers" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabSelectedTextColor="@color/colorPrimary"
app:tabRippleColor="@color/colorGray"
android:layout_marginTop="8dp" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/channelViewPager"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</LinearLayout>
</ScrollView>
Here's my fragment in ViewPager:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.fragments.ChannelAudioFragment">
<ProgressBar
android:id="@+id/allChannelAudiosProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/noAudiosTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
android:gravity="center|left"
android:text="No audios"
android:layout_marginTop="5dp"
android:textSize="15dp"/>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/channelAudiosRefreshSwipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvAllChannelAudios"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
Why is this happening?