Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show tab indicator at top of Tabs

I followed this tutorial. I have made simple change that shows TabLayout at bottom of screen.

activity_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:layout_height="match_parent"
    android:orientation="vertical">


    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager_landing"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1"
        android:background="@android:color/white" />

    <android.support.design.widget.TabLayout
        android:id="@+id/sliding_tabs_landing"
        style="@style/MyCustomTabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="fixed" />

</LinearLayout>

enter image description here

Problem:-

TabIndicator is showing at bottom of screen working well,Now I want to show that TabIndicator at Top of Tabs rather than bottom. Using custom layout we can do that as mentioned in tutorial but is there any xml attribute that will show TabIndicator at top ?

like image 991
N J Avatar asked Sep 17 '15 15:09

N J


People also ask

What is tab layout?

In Android TabLayout is a new element introduced in Design Support library. It provides horizontal layout to display tabs on the screen. We can display more screens in a single screen using tabs. We can quickly swipe between the tabs.


1 Answers

Add this line to your TabLayout in XML

app:tabIndicatorGravity="top"
like image 169
Muhammad Helmi Avatar answered Sep 28 '22 16:09

Muhammad Helmi