Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Actionbar Tabs on bottom of screen

I agree before-hand with anyone who wants to make the argument that tabs should be at the top of the screen, but I can't control the requirements for my app :) . I have to build an app with tabs at the bottom of the screen. I'm using SDK 14 and Actionbars. Is this even possible? I have already built a layout with the tabs at the bottom, but when I add the tabs to the ActionBar, they are automatically rendered at the top of the screen.

Any ideas would be really appreciated, and thank you all for taking the time to read this post.

like image 631
user1956604 Avatar asked Jan 17 '13 14:01

user1956604


People also ask

How do I remove the action bar?

If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme. AppCompat.

Where is action bar in Android?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.

How do you add action items to the action bar in Android?

All action buttons and other items available in the action overflow are defined in an XML menu resource. To add actions to the action bar, create a new XML file in your project's res/menu/ directory. The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar.


1 Answers

You can use Tabhost for requirement,and inside tab.xml you can write below code . This will work fine .

<?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:orientation="vertical"
        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_weight="1" >
                 </FrameLayout>
          <TabWidget 
             android:id="@android:id/tabs"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:tabStripEnabled="false"
            android:layout_alignBottom="@android:id/tabcontent"
            android:background="#000000" />
          </RelativeLayout>
</TabHost>
like image 174
krishnendra Avatar answered Sep 30 '22 03:09

krishnendra