D
D
dimasik1002002017-12-07 19:35:09
Android
dimasik100200, 2017-12-07 19:35:09

How to create tabs in fragment?

I have a Navigation Drawer and it contains several fragments. In one of them I want to add a TabLayout. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Marken, 2017-12-08
@dimasik100200

You place a TabItem on the TabLayout layout. Here is an example:

<android.support.design.widget.TabLayout
    android:id="@+id/tabLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabIndicatorColor="@color/white"
    app:tabMode="scrollable"
    app:tabSelectedTextColor="@color/colorText"
    app:tabTextColor="@color/colorSecondaryText">

    <android.support.design.widget.TabItem
      android:id="@+id/tabItem1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Tab1" />
</android.support.design.widget.TabLayout>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question