Search code examples
androidfragmentinvisible

Android Fragment Tabbar - Invisible on Main Page?


I have a custom tabbar on the bottom of my android view. I would like to have it "GONE" on the mainpage, because the main page content should take the entire height available.

But it seems to me, that even when I set visibility="gone" the 100dp height of the tabbar is still taken into account when rendering the mainpage, as the content view is not of full height.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" android:gravity="center_horizontal">

    <FrameLayout android:layout_width='fill_parent'
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical" android:id="@+id/content">

   </FrameLayout>

   <fragment android:name="MainActivity$TabBarFragment"
    android:visibility="gone"
    android:id="@+id/tabbar"
    android:layout_weight="1"
    android:layout_width="fill_parent"
    android:layout_height="100dp"/>

How can I get the ContentView to take full height at the mainpage?


Solution

  • Found it by myself.

    I am now using:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" android:gravity="center_horizontal">
    
    <FrameLayout android:layout_width='fill_parent'
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="vertical" android:id="@+id/content">
    
    </FrameLayout>
    
    <fragment android:name="MainActivity$TabBarFragment"
        android:id="@+id/tabbar"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
    

    and instead the TabBarFragment Layout File defines it's height and defines visibility=gone. That works.