Android: Tabs at the BOTTOM

后端 未结 10 2151
长发绾君心
长发绾君心 2020-11-22 05:03

I\'ve seen some chatter about this, but nothing definite. Is there a way to put the tabs in a TabWidget to the bottom of the screen? If so, how?

I\'ve tried the fol

相关标签:
10条回答
  • 2020-11-22 05:21

    I recomend use this code for stable work, it optimized for nested fragments in tab (for example nested MapFragment) and tested on "do not keep activities": https://stackoverflow.com/a/23150258/2765497

    0 讨论(0)
  • 2020-11-22 05:22

    Try it ;) Just watch the content of the FrameLayout(@id/tabcontent), because I don't know how it will handle in case of scrolling... In my case it works because I used ListView as the content of my tabs. :) Hope it helps.

    <?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: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_alignParentTop="true" 
                 android:layout_above="@android:id/tabs" />
        <TabWidget android:id="@android:id/tabs"
                 android:layout_width="fill_parent" 
                 android:layout_height="wrap_content"
                 android:layout_alignParentBottom="true" />
        </RelativeLayout>
    </TabHost>
    
    0 讨论(0)
  • 2020-11-22 05:29

    There are two ways to display tabs at the bottom of a tab activity.

    1. Using relative layout
    2. Using Layout_weight attribute

    Please check the link for more details.

    0 讨论(0)
  • 2020-11-22 05:29

    I was having the same problem with android tabs when trying to place them on the bottom of the screen. My scenario was to not use a layout file and create the tabs in code, I was also looking to fire activities from each tab which seemed a bit too complex using other approaches so, here is the sample code to overcome the problem:

    adding-tabs-in-android-and-placing-them

    0 讨论(0)
提交回复
热议问题