Я хочу закрепить TabLayout при прокрутке
Я попробовал ... код. но не могу закрепить TabLayout под панелью инструментов
В этом у меня есть панель инструментов и ниже, у меня есть scrollview, а внутри этого scrollview у меня много раскладок ...
Я хочу закрепить TabLayout, который выше ViewPager (внизу). Когда я прокручиваю вниз, закрепляется tabLayout и отображается пейджер вида (выглядит примерно так, как tabLayout закреплен под панелью инструментов).
Вот пример изображения: https://imgur.com/dGddsey
Пример видео: https://drive.google.com/open?id=146UaY89cgxQ3XJyZb1Uos-JQjurDL2hW
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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EAEAEA"
android:orientation="vertical"
tools:context=".MainActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#03A9F4"
android:elevation="3dp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:padding="4dp"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="180dp"
android:elevation="2dp"
app:cardCornerRadius="20dp"
app:cardUseCompatPadding="true" />
<androidx.cardview.widget.CardView
android:id="@+id/live_wallpaper_card"
android:layout_width="match_parent"
android:layout_height="120dp"
android:elevation="2dp"
app:cardCornerRadius="20dp"
app:cardUseCompatPadding="true" />
<!--Todo: horizontal card scroll-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:text="Category"
android:textColor="#000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/more_textTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="More"
android:textStyle="bold" />
</RelativeLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="15dp"
app:cardUseCompatPadding="true" />
<androidx.cardview.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="15dp"
app:cardUseCompatPadding="true" />
<androidx.cardview.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="15dp"
app:cardUseCompatPadding="true" />
<androidx.cardview.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="15dp"
app:cardUseCompatPadding="true" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
<!--Todo: Featured Album horizontal scroll view-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Featured Albums"
android:textColor="#000"
android:textSize="16sp"
android:textStyle="bold" />
</RelativeLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="300dp"
android:layout_height="220dp"
app:cardCornerRadius="20dp"
app:cardUseCompatPadding="true" />
<androidx.cardview.widget.CardView
android:layout_width="300dp"
android:layout_height="220dp"
app:cardCornerRadius="20dp"
app:cardUseCompatPadding="true" />
<androidx.cardview.widget.CardView
android:layout_width="300dp"
android:layout_height="220dp"
app:cardCornerRadius="20dp"
app:cardUseCompatPadding="true" />
<androidx.cardview.widget.CardView
android:layout_width="300dp"
android:layout_height="220dp"
app:cardCornerRadius="20dp"
app:cardUseCompatPadding="true" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_bright"
app:tabIndicatorColor="@color/colorPrimary"
app:tabIndicatorHeight="3dp"
app:tabSelectedTextColor="@color/black"
app:tabTextColor="@android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="650dp"
android:background="@color/colorPrimaryDark" />
</LinearLayout>
<!--
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
</LinearLayout>
-->
</LinearLayout>
</ScrollView>
</LinearLayout>