Android - Tabs in bottom of screen

前端 未结 10 1727
有刺的猬
有刺的猬 2020-12-30 15:06

I have been looking for about a day for a way to get my android application have tabs in the bottom of the screen.

On the Android Developer website in the Styles and

相关标签:
10条回答
  • 2020-12-30 15:23

    Its very simple....

    For simple tab bar we use

    <?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:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="5dp" />
        </LinearLayout>
    </TabHost>
    

    But in Bottom Tab bar we use

    **

    <?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_height="fill_parent"
            android:layout_width="fill_parent">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_alignParentBottom="true"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="5dp" />
        </RelativeLayout>
    </TabHost>**
    

    The main thing is

     android:layout_alignParentBottom=”true”;
    
    0 讨论(0)
  • 2020-12-30 15:27

    I think you have not search enough for your problem because you are searching using the wrong keyword.

    What you are showing in 1st image at bottom of gmail app there are 4 menu and 5th overflow menu and upper at top action bar

    You can place a menu at the bottom using a simple property in the manifest; one single line on main activity which showing action bar

    android:uiOptions="splitActionBarWhenNarrow"

    Like this :

    <activity
        android:name="com.example.HomeActivity"
        android:screenOrientation="portrait"
            android:uiOptions="splitActionBarWhenNarrow"
        android:theme="@style/Theme.Sherlock.Light" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
    
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    
    0 讨论(0)
  • 2020-12-30 15:28

    Google does not recommend to have Tabs at the bottom.

    See the following official design pattern guide from Android,
    And look for the section "Don't use bottom tab bars"

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

    0 讨论(0)
  • 2020-12-30 15:33

    I use this layout for locate Tabs in bottom of screen:

    ?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="match_parent"
        android:layout_height="match_parent">
    
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <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:background="@drawable/bg_main_app_gradient"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"/>
            <TabWidget
                android:id="@android:id/tabs"
                android:background="#EAE7E1"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0"/>
        </LinearLayout>
    </TabHost>
    

    examle of code: https://stackoverflow.com/a/23150258/2765497

    0 讨论(0)
  • 2020-12-30 15:34

    Here is the two link of github that has implemented tab at bottom.

    enter image description here

    https://github.com/AdilSoomro/Iphone-Tab-in-Android

    enter image description here

    https://github.com/AdilSoomro/Raised-Center-Tab-in-Android

    0 讨论(0)
  • 2020-12-30 15:35

    I think these examples will be useful to you: Android Bottom tab bar example AND THIS

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