Skip to main content

Tabs at the bottom of TabActivity

Tabs at the bottom of TabActivity

By default tabs in Android are displayed at the top. It is a general guideline for android developers to keep the tabs at top of the Tabs based application since lot of Android mobiles are having their home, back,search buttons or touch interface at the bottom

But its purely our decision :)

There are two ways to achieve this.
  1. Using RelativeLayout
  2. Using "android:layout_weight" attibute
 1) Using RelativeLayout: .xml will look like the following.
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <FrameLayout android:id="@android:id/tabcontent"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:layout_alignParentTop="true"
             android:layout_above="@android:id/tabs" />
    <TabWidget android:id="@android:id/tabs"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:layout_alignParentBottom="true" />
    </RelativeLayout>
</TabHost>

2)  Using "android:layout_weight" attibute
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:layout_weight="1"/>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"/>
    </LinearLayout>
</TabHost>
  

I have  used both approaches in my application. It is working fine without any problem.

Comments

Angel H. said…
Muchisimas Gracias!!!!
Brian Murphy said…
This did not work when using "android.support.v4.app.FragmentTabHost" as a TabHost.

Popular posts from this blog

Why a gaming startup? FirstSeed!

I write occasionally. This time I would like to share about why I started game development studio FirstSeed.

Many of you might wonder why this guy chose this field? I would like to add reasons for selecting game development as my core business. During my school days, I played "9999999 in 1" handheld console games. It was interesting those days. Later got an opportunity to play TV Console game. I got to play games like Mario, Contra, BaseBall, Bomberman. I loved these games to the core. This was the first time I felt so much connected to something. I got a feel of myself jumping there. Whenever I pressed Jump button, together with Mario me too jumped a little bit. So I was always finding excuses to play games.

During my higher secondary education, got into PC games and played Need for Speed, Road Rash, EA Cricket. These games entertained me very well. But Age of Empires II and Red Alert 2 are no more just games during that time. They were life during those days. Actually, we…

Me and FirstSeed so far....

FirstSeed is more than two and half years old now. Released three games to Google Play Store. I have a team of good individuals working with me. They are doing quite good in their jobs. Running a game studio is not a joke. But, we enjoy doing it.

How much money I have made so far? 🤣 .  We are still learning many areas of game making and releasing.

How much money I have invested? $$$. Without my father's support, my wife's support and my friends' support it is not possible to run a startup without making much money.

We earlier focussed on mobile game development alone. Now, We have brought PC games too under our focus. We are building our next PC Game "Quest of Vidhuraa". Will be released by end of 2017.

And we are having a mobile game "To My Home" to be released soon. "To My Home" is a mix of everything. A thrill and exposure to the team. So many reschedules it has met for the past two years. "YET TO BE LAUNCHED"

We are yet to meet…