How to show tab bar below, -Tab with snippet

I am developing a tab-based Android application, I saw that the "TabActivity" class is deprecated and instead uses a snippet to achieve the same, I used the following link and developed my application, now I need to show the tab bar at the bottom, I tried several ways, but could not get it to work correctly,

http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/

Can someone help me with this, my xml tab layout

<?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> 
+4
source share
4 answers

First get rid of the external LinearLayout, this is useless. Then put your TabWidget in the last position of your inner LinearLayout, and you're done.

+9
source
 <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

+1
source

assign the vertical orientation to the internal vertical orientation and place the Host tab at the last position of the Linear Layout.

0
source

Whatever the case, the bottom tab today is an anti-UX pattern

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

-3
source

All Articles