2

Hi I am using FragmentTabHost to display some tabs in my application. Tabs are displayed but not appearing at the bottom. Here is my layout code for activity

<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

    <TabWidget
        android:id="@android:id/tabs"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"/>

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="0"/>

    <FrameLayout
        android:id="@+android:id/realtabcontent"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

</LinearLayout>

The code I used to display is taken from Android documentation. My problem is tabs are always on top and they're not appearing at the bottom

Onur A.
  • 3,007
  • 3
  • 22
  • 37
Bora
  • 1,933
  • 3
  • 28
  • 54

2 Answers2

2

Actually it's against Android Design Guideline since at bottom there are soft/hard buttons like back button home button etc.

http://developer.android.com/design/patterns/pure-android.html

But if you insist on to put them at the bottom, you should tweak it, there have been an already implemented one below https://github.com/rameshkec85/BottomTabsFragmentTabHost

Onur A.
  • 3,007
  • 3
  • 22
  • 37
  • A . Hi, I tried this solution it works great. I have a little situation with this . Actually i want to replace one fragment with other and i am able to do that also .however when i go back to some other tab and then come back again it ends with an no activity error – Bora Sep 05 '13 at 12:39
  • I have asked this question in stackoverflow but no one answered http://stackoverflow.com/questions/18635403/fragmenttabhost-no-activity-illegalstateexception-error – Bora Sep 05 '13 at 12:40
  • hımm can you clarify a bit, maybe post some code? i couldnt figure it out so far – Onur A. Sep 05 '13 at 13:36
  • can i mail you in your email id ? – Bora Sep 05 '13 at 14:01
  • i will take a look at your post, btw someone already answered, check it out – Onur A. Sep 05 '13 at 14:06
1

Try this: https://stackoverflow.com/a/23150258/2765497 simple chenge TabHost to android.support.v4.app.FragmentTabHost for support Api<11

Community
  • 1
  • 1
Oleksandr B
  • 3,400
  • 1
  • 25
  • 28