Reputation: 6395
I'm developing a tab based android application,I have seen that "TabActivity" class is deprecated and instead use the Fragment to achieve the same, I used the following link and develop my application, now I need to show the tab bar in the bottom, I tried few ways but could not get it work correctly,
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
Can some one help me on this, my tab layout xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost
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"
>
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="fill_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="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</TabHost>
</LinearLayout>
Upvotes: 4
Views: 8305
Reputation: 668
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<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:background="#ff140c14">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
</RelativeLayout>
Works for me
Upvotes: 1
Reputation: 4587
assign inner linear layout orientation vertical and put the Tab Host in the last position of Linear Layout.
Upvotes: 0
Reputation: 1370
Whatever, bottom Tabbar today is a UX anti-pattern
http://developer.android.com/design/patterns/pure-android.html
Upvotes: -3
Reputation: 786
First get rid of the outer LinearLayout, it's useless. Then put your TabWidget in last position of your inner LinearLayout and you're done.
Upvotes: 9