Retain position in Nested Scroll View having FrameLayout

29 views Asked by At

I have a nested scroll view which has different types of frame layout. Each frame layout acts as a container for fragment. As soon I click any fragment I am moved to another fragment which is not inside nested frame layout. Soon as I close this newly opened fragment I want to exactly positioned the scroll position where I opened it.

<androidx.core.widget.NestedScrollView
    android:id="@+id/nestedScrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:overScrollMode="never"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/abcCardsSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone" />

        <FrameLayout
            android:id="@+id/defUserSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"/>

        <FrameLayout
            android:id="@+id/ghiUserSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"/>

        <FrameLayout
            android:id="@+id/123Section"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"/>

        <FrameLayout
            android:id="@+id/vvvvvvSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"/>

        <FrameLayout
            android:id="@+id/highlightStorySection"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone"/>

        <FrameLayout
            android:id="@+id/zsjljon"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"/>

        <FrameLayout
            android:id="@+id/bbbbTrackerSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"/>

        <FrameLayout
            android:id="@+id/exploreOurSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@+id/fngCard"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

</androidx.core.widget.NestedScrollView>

On my Call to action button, highlightStorySection framelayout opens which hosts a fragment. As soon as I close this newly opened fragment I want to position the view/frame layout on the same position where it was in the nested scroll view but without any animation/slide/ transition.

0

There are 0 answers