7

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 ?

halfer
  • 19,824
  • 17
  • 99
  • 186
N J
  • 27,217
  • 13
  • 76
  • 96

2 Answers2

4

Add this line to your TabLayout in XML

app:tabIndicatorGravity="top"
Muhammad Helmi
  • 395
  • 2
  • 10
0

This worked for me:

LinearLayout tabs = ((LinearLayout) tabLayout.getChildAt(0));

for (int position = 0; position < tabs.getChildCount(); position++) {
    LinearLayout item = ((LinearLayout) tabs.getChildAt(position));
    item.setRotationX(180);
}
shmakova
  • 6,076
  • 3
  • 28
  • 44