0

I'm trying to spread out these tabs on my app. I have looked around but I can't find anything about it.

The tabs.

What I want is Tab1 to be on the left, Tab3 on the way right and Tab2 in the middle.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

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

        <android.support.design.widget.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Tab1" />

        <android.support.design.widget.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Tab2" />

        <android.support.design.widget.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Tab3" />
    </android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.master.moonbot.MoonBot">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
kuantum
  • 173
  • 1
  • 2
  • 8

1 Answers1

0

Delete app:tabMode="scrollable" and it will default to fixed.

<android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
parkgrrr
  • 738
  • 7
  • 12