How can I set the height of ScrollView to adapt with different Fragment?

15 Views Asked by At

I have a Navigation.xml in which I use ScrollView with FrameLayout to pour Fragment but when I add another Fragment to replace the old Fragment , the new Fragment which has smaller height than the old one expanded to fit the ScrollView

this is Navigation.xml layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Activity.Navigation">

    <ScrollView
        android:layout_above="@+id/bottom_nav"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <FrameLayout
            android:orientation="vertical"
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/blackbackground"
            />
    </ScrollView>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_nav"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:itemBackground="@color/blackbackground"
        app:itemIconTint="@color/white"
        app:itemTextColor="@color/bottom_item_menu_color"
        app:menu="@menu/bottom_menu"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

This is the first Fragment : enter image description here enter image description here

This is the second Fragment (when the first one is replaced , the new Fragment started from the bottom of the screen and only when I scroll it up then it showed up) : enter image description here enter image description here

I expected the ScrollView with FrameLayout will adjust its height to fit new Fragment but it didn't . How can I achieve it ?

0

There are 0 best solutions below