Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set the tabs in the bottom of the screen in android?

i am working on tabactivity.

i wanna show my tabwidget below the tabcontent(framelayout).

i done it by setting the tabwiget tab attribute as

android:gravity="bottom"

but the framelayout cant align with those tabs.

that is the tabs are shown at the bottom of the screen and overlap the framelayout

how to do that? if set some height value to the framelayout it not optimized for all screens of android. what can i do? any idea???

like image 273
Praveen Avatar asked Mar 08 '10 12:03

Praveen


2 Answers

The basic concept behind the Tab-Activity as follows

TabHost is a container for a tabbed window view. This object holds two children: a set of tab labels that the user clicks to select specific tab, and a FrameLayout object that displays the content of that page.

The individual element are typically controlled using this container object, rather then setting values on the child elements themselves.

TabWidget displays a list of tab labels representing each page in the parent's tab collection. The container object for this widget is TabHost. When a user selects a tab, this object sends a message to container, TabHost, to tell to switch the display page. The container TabHost is used to add labels, add the callback handler, and manage callbacks.

so adjust your layout as follows -

<?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:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

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

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="-3dip"
        android:layout_weight="0" >
    </TabWidget>
  </LinearLayout>

  </TabHost>
like image 130
Swapnil Sonar Avatar answered Sep 23 '22 04:09

Swapnil Sonar


or just use a custom one from: http://code.google.com/p/androidtabs/

it allows tabs on the bottom

like image 39
reflog Avatar answered Sep 21 '22 04:09

reflog