0

In my application i set Navigation Drawer and Tabs the following code is for Tabs and i am trying to fixed in bottom but it is not working at all.

main.xml

<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical"
    android:layout_height="wrap_content">


    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        app:tabGravity="fill"
        app:tabMode="fixed"
        android:background="@color/material_blue_grey_800"
        app:tabIndicatorColor="@color/orange"
        app:tabSelectedTextColor="@color/orange"
        app:tabTextColor="@color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </android.support.v4.view.ViewPager>



</LinearLayout>

I want to set Tabs in bottom can anyone tell me how to set Tabs in Bottom using this code?

  • visit this : http://stackoverflow.com/questions/33380668/how-to-set-android-tablayout-in-the-bottom-of-the-screen – Harshad Pansuriya Sep 14 '16 at 08:14
  • 1
    @Ironman thank you so much it is working perfectly... and can we set an icon instead of text? and should i post my java code for it? –  Sep 14 '16 at 09:44

1 Answers1

0

You need to change order in the LinearLayout. Viewpager will up and TabLayout will be down.

After that viewpager need to give weight property to 1.

<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical"
    android:layout_height="wrap_content">

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="match_parent">
    </android.support.v4.view.ViewPager>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        app:tabGravity="fill"
        app:tabMode="fixed"
        android:background="@color/material_blue_grey_800"
        app:tabIndicatorColor="@color/orange"
        app:tabSelectedTextColor="@color/orange"
        app:tabTextColor="@color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </android.support.design.widget.TabLayout>
</LinearLayout>
Shabbir Dhangot
  • 8,954
  • 10
  • 58
  • 80
  • i already got it from the above link... but now i want to set an icon instead of text. so can u please suggest me the answer? –  Sep 14 '16 at 11:10
  • I already gave answer here, http://stackoverflow.com/a/39488685/2900893 – Shabbir Dhangot Sep 14 '16 at 11:11