'Why Android Fragment Tab Height Decreased?

I have added two tabs in my activity named as ANIMAL DATA and NOTES. When i do switch to second tab named NOTES and return back to Animal data tab then my Animal Data tab layout height decreased automatically.

See my issue : Before image is the normal tab of animal data. when do switch to next notes tab and return back to animal data tab then After img is shown.

tab switching issue

My ANIMAL DATA layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:background="?activityBackground"
    tools:context=".Fragments.AnimalViewDataFragment">

    <RelativeLayout
        android:background="?cardBackgroundColor"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/animalsMainIcon"
                style="@style/mystylee" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:orientation="vertical">

                <TextView
                    android:text="Animal Category"
                    style="@style/mystyle" />

                <TextView
                    android:id="@+id/aniViewAniCateg"
                    style="@style/mystyle1" />

                <TextView
                    android:text="Animal Type"
                    style="@style/mystyle" />

                <me.grantland.widget.AutofitLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <me.grantland.widget.AutofitTextView
                        android:id="@+id/aniViewAniType"
                        style="@style/mystyle1">

                    </me.grantland.widget.AutofitTextView>

                </me.grantland.widget.AutofitLayout>

                <TextView
                    android:text="Animal Count"
                    style="@style/mystyle" />

                <TextView
                    android:id="@+id/aniViewAniCount"
                    style="@style/mystyle1" />

                <TextView
                    android:text="Animal Cost"
                    style="@style/mystyle" />

                <TextView
                    style="@style/mystyle"
                    android:id="@+id/aniViewAniCost" />

                <TextView
                    android:text="Description / Note"
                    style="@style/mystyle" />

                <me.grantland.widget.AutofitLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="10dp">

                    <me.grantland.widget.AutofitTextView
                        android:id="@+id/animViewDesc"
                        style="@style/mystyle1" />
                </me.grantland.widget.AutofitLayout>
            </LinearLayout>
        </LinearLayout>
    </RelativeLayout>
</RelativeLayout>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source