Search code examples
androidandroid-fragmentsandroid-tabhost

Android TabLayout and Fragments


I have been learning Android for a few months but I have several questions I can't find solution. Recently, I follow a few tutorials where there explain about TabLayout, Fragments and RecyclerView but that is not worth for me. I need an Android interface which a few tabs, with diferent content, but what I need is to enable scroll. This is my code:

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinator_main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">

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


    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:layout_scrollFlags="scroll|enterAlways" />

</android.support.design.widget.AppBarLayout>


<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />


Solution

  • SOLUTION: To fix this, we have to use NestedScrollView