0

How to place the TabLayout at bottom of screen in Android?

Following is my layout file where TabLayout is just below toolbar:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="in.brewtv.activities.HomeActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay">

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"
            android:fillViewport="false" />


    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>

Could have been easy with RelativeLayout, but android:layout_alignParentBottom="true does not seem to work with CoordinatorLayout.

jay
  • 1,982
  • 2
  • 24
  • 54
  • You can do it easily using a RelativeLayout, see here: http://stackoverflow.com/questions/32984706/how-can-i-set-tabs-at-the-bottom-and-also-hide-top-actionbar – Daniel Nugent Mar 27 '17 at 15:14
  • Check this solution... worked for me https://stackoverflow.com/questions/41481536/android-tablayout-on-the-bottom-of-the-screen – Abuzaid Aug 06 '17 at 16:32

0 Answers0