VerticalScroll not working for Column composable when having a ScrollView as parent in xml. Using ComposeView inside an xml

76 Views Asked by At

I am having an xml file where the parent layout is a ScrollView. This is an old code and we wanted to add new functionality in the same page using Jetpack Compose. So we are using ComposeView inside ScrollView in xml.

The Composable Functions are getting displayed correctly. But the verticalScroll which I applied for a Column is not working. I feel it is conflicting with ScrollView. If I remove the parent layout ScrollView from xml then Compose Scroll is working fine.

Is there any way we can achieve this ? Like nestedScrolling and how we used to do in old days with xml. With NestedScrollView and a RecyclerView.

If I change the entire layout to Composable then the nested scroll should work. But changing the entire layout to composable is no easy task since we need to rework on so many design and functionality.

I have like this in my layout file. This is shown to get a rough idea on the structure of my layout file

<ScrollView
     android:id="@+id/scroll_view"
     android:width="match_parent"
     android:height="match_parent">

     <RelativeLayout
          android:width="match_parent"
          android:height="wrap_content">
          
          <CardView
               android:width="match_parent"
               android:height="500dp">


          <CardView>
     </RelativeLayout>

     <RelativeLayout
          android:width="match_parent"
          android:height="wrap_content">
          
          <androidx.compose.ui.platform.ComposeView
               android:width="match_parent"
               android:height="500dp" />
     </RelativeLayout>
</ScrollView>

Inside the compose view we will be having a list which should be scrollable and the parent should also be scrollable.

Any suggestions will greatly appreciated.

0

There are 0 best solutions below