0
<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:theme="@style/AppTheme.AppBarOverlay">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"/>
    <android.support.design.widget.TabLayout
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="scrollable"/>
</android.support.design.widget.AppBarLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">
    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1"
        android:background="@android:color/white"/>
</LinearLayout>

However the following is the layout which is presented on the screen. I can't get the tabs to align to the bottom of the AppbarLayout. Is there a way for them to align to bottom?

enter image description here

JY2k
  • 2,879
  • 1
  • 31
  • 60

2 Answers2

0

If you see the Android documentation, AppBarLayout is a child of LinearLayout. So you should be able to force the child views to the bottom similarly as you would in LinearLayout - using weights. You can just simply add a Space widget to take the remaining space between the Toolbar and the TabLayout and give them the desired weights (you may have to do a little trial and error to arrive at the precise weight value).

ucsunil
  • 7,378
  • 1
  • 27
  • 32
0

You can simply enclose your TabLayout inside a LinearLayout with height match_parent and setting gravity to bottom. Something like this

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="bottom">
<android.support.design.widget.TabLayout
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="scrollable"/>
</LinearLayout

Hope this will work.

Mukesh Rana
  • 4,051
  • 3
  • 27
  • 39