Scrollable fragment in ConstraintLayout - Android - android

I would like to create an app with a layout like this
There are three fragments with some of views. Unfortunately, I can't scroll up or down in the fragments of the viewpager. For example, I can't scroll the text in this fragment
Here is the code of my layout:
<android.support.constraint.ConstraintLayout 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">
<ImageView
android:id="#+id/iv_1"
android:layout_width="0dp"
android:layout_height="250dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#color/colorPrimary" />
<ImageView
android:id="#+id/iv_2"
android:layout_width="0dp"
android:layout_height="62dp"
android:background="#drawable/scrim_gradient"
app:layout_constraintBottom_toBottomOf="#+id/1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<EditText
android:id="#+id/et_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:ems="10"
android:hint="Name"
android:inputType="textCapWords"
android:maxLines="1"
android:textAppearance="#style/TextAppearance.AppCompat.Display1"
android:textColor="#color/white"
android:textColorHint="#color/whiteGreyish"
app:layout_constraintBottom_toBottomOf="#+id/iv_challenge_cover_image"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/iv_2"
app:layout_constraintRight_toRightOf="#+id/iv_2" />
<ImageView
android:id="#+id/btn_add_cover"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toTopOf="#+id/iv_2"
app:layout_constraintRight_toRightOf="#+id/iv_1"
app:srcCompat="#drawable/ic_add_a_photo" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_marginTop="0dp"
android:elevation="2dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/iv_1"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/whiteGreyish"
app:tabTextColor="#color/white" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/action_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="#drawable/ic_cloud_upload" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tabs"
app:layout_constraintVertical_bias="1.0">
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="false">
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
</LinearLayout>

Related

Listener of Recyclerview inside NestedScrollView not fired

I have a recyclerview inside of NestedScrollView.
I need scrollListener on both of them but, only nestedScrollView Listener fired.
I do solutions below but problem not solved:
1- I change value of nestedScrollEnabled property in recyclerview and problem not solved
2- I add app:layout_behavior="#string/appbar_scrolling_view_behavior" property on both of them(nested and recyclerview)
Please note that I need both of listeners.
Please help me to solve this problem
<androidx.coordinatorlayout.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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.fragment.store_details.StoreDetailsFragment">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="2dp"
app:elevation="2dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
style="#style/ToolbarStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="#+id/toolbar">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/csr_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/grayLight"
app:layout_collapseMode="parallax">
<ImageView
android:id="#+id/img_banner"
android:layout_width="0dp"
android:layout_height="0dp"
android:contentDescription="#null"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_constraintDimensionRatio="H,6:4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tv_delivery_price"
style="#style/M12A100Dark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/bg_white_radius_huge"
android:paddingHorizontal="8dp"
android:paddingVertical="2dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Delivery: 4500T"
tools:visibility="visible" />
<TextView
android:id="#+id/tv_min_price"
style="#style/M12A100Dark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:background="#drawable/bg_white_radius_huge"
android:paddingHorizontal="8dp"
android:paddingVertical="2dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="#id/tv_delivery_price"
app:layout_constraintStart_toEndOf="#id/tv_delivery_price"
app:layout_constraintTop_toTopOf="#id/tv_delivery_price"
tools:text="MIN. ORDER: 60,000 T"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:elevation="2dp"
app:elevation="2dp"
app:layout_collapseMode="pin">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical">
<com.makeramen.roundedimageview.RoundedImageView
android:id="#+id/img_search"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="16dp"
android:background="#color/mediumLight"
android:src="#drawable/ic_search_round"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:riv_mutate_background="true"
app:riv_oval="true" />
<com.makeramen.roundedimageview.RoundedImageView
android:id="#+id/img_back"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#color/mediumLight"
android:src="#drawable/ic_back_round"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:riv_mutate_background="true"
app:riv_oval="true" />
<TextView
android:id="#+id/tv_title"
style="#style/B16A100Dark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:translationY="?actionBarSize"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/img_search"
app:layout_constraintStart_toEndOf="#id/img_back"
app:layout_constraintTop_toTopOf="parent"
tools:text="Title" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:visibility="visible">
<androidx.core.widget.NestedScrollView
android:id="#+id/nested"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingBottom="80dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/csr_top_part"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:paddingHorizontal="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/tv_store_name"
style="#style/O32A100Dark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toStartOf="#id/btn_like"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Bombe Navab Fast Food" />
<com.google.android.material.button.MaterialButton
android:id="#+id/btn_like"
style="#style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:icon="#drawable/ic_outline_favorite"
app:iconSize="24dp"
app:iconTint="#color/primaryDark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:rippleColor="#color/lightGray" />
<TextView
android:id="#+id/tv_store_description"
style="#style/R16A100Dark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="#id/btn_like"
app:layout_constraintStart_toStartOf="#id/tv_store_name"
app:layout_constraintTop_toBottomOf="#id/tv_store_name"
tools:text="I'm loving it!" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/csr_details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:paddingHorizontal="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/csr_top_part">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/csr_rate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingVertical="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/img_rate"
android:layout_width="16dp"
android:layout_height="16dp"
android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_rate_3" />
<TextView
android:id="#+id/tv_rate"
style="#style/R14A100Dark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/img_rate"
app:layout_constraintTop_toTopOf="parent"
tools:text="Amazing 9.6" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/csr_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingVertical="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/csr_rate">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/img_time"
android:layout_width="16dp"
android:layout_height="16dp"
android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_time"
app:tint="#color/primaryDark" />
<TextView
android:id="#+id/tv_time"
style="#style/R14A100Dark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:ellipsize="end"
android:maxLines="2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/bt_more_time"
app:layout_constraintStart_toEndOf="#id/img_time"
app:layout_constraintTop_toTopOf="parent"
tools:text="Open . Closes at 20:45" />
<com.google.android.material.button.MaterialButton
android:id="#+id/bt_more_time"
style="#style/TonalButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
android:text="#string/more_info"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/csr_delivery"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingVertical="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/csr_time">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/img_delivery"
android:layout_width="16dp"
android:layout_height="16dp"
android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_bike"
app:tint="#color/primaryDark" />
<TextView
android:id="#+id/tv_delivery"
style="#style/R14A100Dark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toTopOf="#id/tv_delivery_address"
app:layout_constraintStart_toEndOf="#id/img_delivery"
app:layout_constraintTop_toTopOf="parent"
tools:text="Delivery in 20 - 30 min" />
<TextView
android:id="#+id/tv_delivery_address"
style="#style/R14A64Dark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/img_delivery"
app:layout_constraintTop_toBottomOf="#id/tv_delivery"
tools:text="Berlin" />
<com.google.android.material.button.MaterialButton
android:id="#+id/bt_change_delivery"
style="#style/TonalButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Change" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/csr_super_market"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/csr_details">
<TextView
android:id="#+id/tv_find_what_you_want"
style="#style/O20A100Dark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:text="#string/find_what_you_want"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_supermarket_category"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:clipToPadding="false"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/tv_find_what_you_want"
tools:listitem="#layout/item_supermarket_category" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_menu_products"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingBottom="80dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/csr_details"
tools:listitem="#layout/item_product_full_width" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_menus"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="horizontal"
android:overScrollMode="never"
android:paddingHorizontal="16dp"
android:paddingVertical="16dp"
android:visibility="invisible"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="#layout/item_menu_horizontal_unselected" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<include
android:id="#+id/layout_submit_order"
layout="#layout/layout_submit_order"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="16dp"
android:visibility="gone" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="16dp"
android:visibility="invisible">
<include
layout="#layout/item_menu_horizontal_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I want listener on NestedScrollView & rv_menu_products

Issue adding "app:layout_behavior" in Constraint layout for collapsing toolbar

I am facing one issue since past few days. Below is the issue details.
I need to hide the top layout while scrolling the recyclerview, for that I am using "app:layout_behavior" in Coordinator layout with Collapisng toolbar.But after adding "app:layout_behavior="#string/appbar_scrolling_view_behavior" in Coordinator layout a blank space is coming at the top of the "com.customviewtext.customviews.recyclerviews.TrayRecyclerView". That recyclerview should start from the top of the layout.
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraint_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
<com.customviewtext.customviews.recyclerviews.TrayRecyclerView
android:id="#+id/main_home_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:visibility="visible"
android:orientation="vertical"
android:paddingBottom="#dimen/page_margin_bottom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
/>
<ImageView
android:id="#+id/l3_menu_back"
android:layout_width="#dimen/dimens_30dp"
android:layout_height="#dimen/dimens_30dp"
android:layout_marginStart="#dimen/l3_back_icon_margin"
android:layout_marginTop="#dimen/l2_menu_margin_top"
android:contentDescription="#string/no_go_back"
android:paddingTop="#dimen/dimens_5dp"
android:paddingBottom="#dimen/dimens_5dp"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/back_arrow" />
<com.customviewtext.fab.custom.CustomFabButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom|start"
android:layout_marginEnd="#dimen/dimens_10dp"
android:layout_marginBottom="#dimen/dimens_86dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<pl.droidsonroids.gif.GifImageView
android:id="#+id/gifFLoat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="#dimen/dp_10"
android:layout_marginBottom="#dimen/dp_100"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="#+id/static_image"
android:layout_width="wrap_content"
android:background="#color/white"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="#dimen/dp_10"
android:layout_marginBottom="#dimen/dp_100"
android:contentDescription="#string/background_image_for_card_view"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<ViewStub
android:id="#+id/cast_minicontroller"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginStart="#dimen/dimens_8dp"
android:layout_marginEnd="#dimen/dimens_8dp"
android:layout_marginBottom="#dimen/minicontroller_bottom"
android:layout="#layout/cast_mini_controller_fragment"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/rl_home_cast"
android:layout_width="#dimen/home_cast_button_size"
android:layout_height="#dimen/home_cast_button_size"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="#dimen/dimens_15dp"
android:layout_marginBottom="#dimen/home_cast_button_bottom_margin"
android:background="#drawable/ic_home_cast_bg_new"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent "
app:layout_constraintEnd_toEndOf="parent">
<androidx.mediarouter.app.MediaRouteButton
android:id="#+id/pt_home_cast_icon"
android:layout_width="#dimen/home_cast_button_size"
android:layout_height="#dimen/home_cast_button_size"
android:layout_centerInParent="true"
android:backgroundTint="#color/white_color"
android:icon="#drawable/common_full_open_on_phone"
android:mediaRouteTypes="user"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:id="#+id/home_fragment_level_two_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/close_fab"
android:layout_width="#dimen/dimens_floating_close_icon"
android:layout_height="#dimen/dimens_25dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="#dimen/dimens_10dp"
android:layout_marginBottom="#dimen/dp_120"
android:src="#drawable/close_floating_button"
android:visibility="gone" />
</FrameLayout>
<ViewStub
android:id="#+id/page_loader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="#layout/layout_skeleton"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ViewStub
android:id="#+id/api_error_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="#layout/api_error"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ViewStub
android:id="#+id/connection_error"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="#layout/connection_error"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/my_appbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/home_top_menu"
android:animateLayoutChanges="true"
android:fitsSystemWindows="true"
>
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="#+id/toolbar">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/top_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/recyclerview_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/click"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/app_name"
android:foregroundGravity="center"
android:scaleType="fitXY"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/sony_liv_logo" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/subscribe_renew_upgrade_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="#+id/click"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/subscribe_button_frame_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/dimens_5dp"
android:paddingTop="#dimen/dimens_2dp"
android:paddingEnd="#dimen/dimens_2dp"
tools:ignore="RtlSymmetry">
<ImageView
android:id="#+id/subscribe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/subscribe"
android:foregroundGravity="center"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/subscribe_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="#dimen/dimens_5dp"
android:textColor="#color/white"
android:textSize="#dimen/l2_menu_text"
app:layout_constraintLeft_toLeftOf="#+id/right_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="RtlSymmetry"
tools:text="hello" />
<ImageView
android:id="#+id/right_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/right_arrow_icon"
android:foregroundGravity="center"
android:paddingStart="#dimen/dimens_2dp"
android:paddingEnd="#dimen/dimens_5dp"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/subscribe_title"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
<View
android:id="#+id/divider_line"
android:layout_width="#dimen/dimen_1dp"
android:layout_height="0dp"
android:layout_marginStart="#dimen/dimens_2dp"
android:background="#color/dark_grey"
android:scaleType="fitXY"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/frameLayout"
app:layout_constraintStart_toEndOf="#+id/frameLayout"
app:layout_constraintTop_toTopOf="#+id/frameLayout">
</View>
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="#+id/search_more_icon"
android:layout_width="#dimen/dimens_25dp"
android:layout_height="#dimen/dimens_25dp"
android:layout_marginEnd="#dimen/dimens_10dp"
android:foregroundGravity="center"
android:padding="#dimen/dp_2"
android:scaleType="fitXY"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.9"
app:layout_constraintStart_toEndOf="#id/subscribe_renew_upgrade_layout"
app:layout_constraintTop_toTopOf="#id/click"
app:srcCompat="#drawable/ic_search_white" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view_l2_menu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:foregroundGravity="center"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#id/click"
app:layout_constraintTop_toBottomOf="#+id/click" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view_l2_menu_navigation_fix"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="#dimen/dimens_18dp"
android:layout_marginTop="5dp"
android:layout_gravity="bottom"/>
<!-- app:tabGravity="fill"
app:tabMode="scrollable"-->
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<data>
<import type="android.view.View" />
<variable
name="sampleData"
type="com.customviewtext.viewmodel.home.SampleViewModel" />
</data>
</layout>
Any help would be appreciated.

How to make ViewPager fit under tabs?

I'm programming an Android application and I have encountered an issue with the height of the ViewPager element. I have search for an answer but I haven't found one yet. My problem is that I cannot make my ViewPager fit under the tabs, it occupies the entire screen:
This is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
tools:context=".frontend.Profile">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
tools:context=".frontend.Profile">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="85dp"
android:layout_height="85dp"
android:src="#drawable/ic_user"
app:civ_border_color="#FF000000"
app:civ_border_width="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.029999971" />
<TextView
android:id="#+id/usernameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/sourcesanspro_regular"
android:gravity="center_horizontal"
android:letterSpacing="0.1"
android:text="John Smith"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.17000002" />
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.24000001">
<com.google.android.material.tabs.TabItem
android:id="#+id/tabRoutines"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Routines" />
<com.google.android.material.tabs.TabItem
android:id="#+id/tabStats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stats" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tabLayout"
app:layout_constraintVertical_bias="1.0">
</androidx.viewpager.widget.ViewPager>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
I would really appreciate if someone could tell me what I'm doing wrong.
Thank you!
You need to constraints the TabLayout to:
Be at the bottom of the TextView with
app:layout_constraintTop_toBottomOf="#+id/usernameText"
And remove the app:layout_constraintTop_toTopOf="parent"
And use a 0dp for the ViewPager height to match constraints.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
tools:context=".frontend.Profile">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="85dp"
android:layout_height="85dp"
android:src="#drawable/ic_user"
app:civ_border_color="#FF000000"
app:civ_border_width="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.029999971" />
<TextView
android:id="#+id/usernameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/sourcesanspro_regular"
android:gravity="center_horizontal"
android:letterSpacing="0.1"
android:text="John Smith"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.17000002" />
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/usernameText">
<com.google.android.material.tabs.TabItem
android:id="#+id/tabRoutines"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Routines" />
<com.google.android.material.tabs.TabItem
android:id="#+id/tabStats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stats" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tabLayout"
app:layout_constraintVertical_bias="1.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

how to make whatsapp like toolbar

I am trying to make whatsapp like appbar
My Code
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="#+id/topAppBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:navigationIcon="#drawable/abc_vector_test"
app:logo="#drawable/ic_baseline_edit_24"
app:subtitle="Me, You"
app:title="Group Name"
app:menu="#menu/chat_room_app_bar"
style="#style/Widget.MaterialComponents.Toolbar.Primary"
>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
The problem is that I am unable to combine display picture with navigationIcon like in whatsapp appbar
and also how to add ripple effect when we click on appbar shown below
This worked for me.
I have made the custom toolbar with imageView in it.
<androidx.coordinatorlayout.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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.chatroom.ChatRoomActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="#+id/topAppBar"
style="#style/Widget.MaterialComponents.Toolbar.Primary"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:orientation="vertical"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:menu="#menu/chat_room_app_bar"
app:title="#null">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/navigationBackButtonChatRoom"
style="#style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_dp"
android:clickable="true">
<ImageView
android:id="#+id/chatRoomDisplayImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/abc_vector_test"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.imageview.ShapeableImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="4dp"
android:background="#null"
android:scaleType="fitXY"
android:src="#drawable/p_p"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/chatRoomDisplayImageView"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="#style/roundedImageViewRounded" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/chatInfoConstraintLayout"
style="#style/Widget.MaterialComponents.Toolbar.Primary"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_margin="0dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:minWidth="540dp">
<TextView
android:id="#+id/titleTextViewChatRoom"
style="#style/TextAppearance.Widget.AppCompat.Toolbar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:text="Group Name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/subtitleTextViewChatRoom"
style="#style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Me, You"
android:visibility="gone"
app:layout_constraintStart_toStartOf="#+id/titleTextViewChatRoom"
app:layout_constraintTop_toBottomOf="#+id/titleTextViewChatRoom" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/messageRecyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="#+id/footerConstraintLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:itemCount="100"
tools:listitem="#layout/chat_row_left_head" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/footerConstraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<ImageButton
android:id="#+id/sendButtonMain"
android:layout_width="47dp"
android:layout_height="47dp"
android:layout_marginEnd="4dp"
android:background="#drawable/input_circle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/input_send" />
<LinearLayout
android:id="#+id/input_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/ib_new_round"
android:gravity="bottom"
android:minHeight="47dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/sendButtonMain"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp">
<ImageButton
android:id="#+id/emojiButtonChatRoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:background="#android:color/transparent"
android:src="#drawable/ib_emoji"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="#color/ibEmojiIconTint" />
<EditText
android:id="#+id/mainEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:autoText="true"
android:background="#null"
android:capitalize="sentences"
android:hint="Type a message"
android:imeOptions="actionSend"
android:maxLines="6"
android:paddingTop="4dp"
android:paddingEnd="8dp"
android:paddingBottom="4dp"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarDefaultDelayBeforeFade="200"
android:scrollbarFadeDuration="300"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:textColor="#color/primary_text"
android:textColorHint="#color/hint_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/attachButton"
app:layout_constraintStart_toEndOf="#+id/emojiButtonChatRoom"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/attachButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="14dp"
android:rotation="-45"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/cameraButton"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ib_attach" />
<ImageView
android:id="#+id/cameraButton"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="12dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_baseline_photo_camera_24" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/scrollToBottomFab"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="12dp"
android:layout_marginBottom="72dp"
android:clickable="true"
app:fabCustomSize="32dp"
app:maxImageSize="24dp"
app:srcCompat="#drawable/ic_baseline_keyboard_arrow_down_24" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

Why does my layout auto scroll without a scroll view?

I have been having some trouble implementing a toolbar but it never stays in one place. This is due to some auto scroll thing with recyclerView in the layout, which I weird since there is no scrollView.
How do I fix this so the tool bar is in a fixed position when I scroll?
Here is my code so you can tell me what I need to do in order to fix it.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
tools:context="com.example.user.app.Utils.ViewProfileFragment">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorS50Alpha"
android:elevation="2dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme" />
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/ivProfileBackphoto"
android:layout_width="0dp"
android:layout_height="320dp"
android:background="#drawable/background_signinandregister"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="#color/colorProfileBack" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="150dp"
android:background="#drawable/shadow_profile_01"
app:layout_constraintBottom_toBottomOf="#+id/ivProfileBackphoto"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
android:id="#+id/relativeLayout5">
</RelativeLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/ivProfilephoto"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="#+id/ivProfileBackphoto"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.361" />
<TextView
android:id="#+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif"
android:text="Foster The People"
android:textAppearance="#style/TextAppearance.AppCompat"
android:textColor="#android:color/white"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="#+id/ivProfileBackphoto"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ivProfilephoto"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintHorizontal_bias="0.497" />
<TextView
android:id="#+id/tvDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginStart="40dp"
android:layout_marginTop="1dp"
android:text="I like bacon and cheese sandwiches"
android:textAlignment="center"
android:textColor="#color/colorGrey"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/ivProfileBackphoto"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvName"
app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="#+id/ivAddFriend"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="#+id/relativeLayout5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#+id/ivProfilephoto"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.418"
app:srcCompat="#drawable/addfriend02" />
<ImageView
android:id="#+id/ivRemoveFriend"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="#+id/relativeLayout5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#+id/ivProfilephoto"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.418"
app:srcCompat="#drawable/removefriend02" />
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tbProfiletabs"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_below="#+id/toolbar01"
android:layout_marginTop="264dp"
android:background="#color/colorS50Alpha"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/relativeLayout5"
app:layout_constraintVertical_bias="0.0"
app:tabSelectedTextColor="#android:color/white"
app:tabTextColor="#color/colorSearch">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Left" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Center" />
</android.support.design.widget.TabLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/lvProfilePosts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/tbProfiletabs"
android:visibility="visible" />
<android.support.v4.view.ViewPager
android:id="#+id/profileTabsViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tbProfiletabs">
</android.support.v4.view.ViewPager>
</RelativeLayout>
Try Changing recycler code like this
<android.support.v7.widget.RecyclerView
android:id="#+id/lvProfilePosts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar01"
android:visibility="visible" />
I think toolbar is staying up there but recycle view is scrolling over the toolbar.
android:focusable="true"
android:focusableInTouchMode="true"
add above lines to your root layout, Relative layout in your case
try this
<RelativeLayout 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="#color/actBackgroundColor"
tools:context="com.playglam.activities.ViewAddressActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBar"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<com.playglam.others.custom_view.MyTextViewThin
android:id="#+id/txtTitle"
android:textColor="#color/colorAccent"
android:textSize="#dimen/font_size_20"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvAddress"
android:layout_marginTop="#dimen/dim_5"
android:layout_below="#+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabNewAddress"
app:srcCompat="#drawable/ic_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/dim_10"
android:layout_marginRight="#dimen/dim_10"
app:elevation="#dimen/dim_5"
app:fabSize="normal"
app:rippleColor="#color/colorAccent" />
I fixed it by adding a NestedScrollView.

Categories

Resources