how to make whatsapp like toolbar - android

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>

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

How do I overlap the Cardview on Image view?

My run time view is not matching with my design view.
my targeted is design .
but when I run on an android device. I got this
How do I overlap the Cardview on Image view?
Does it possible to accomplish. at first, I use FrameLayout then use Relative Layout Now I am out of my option.
Here is my design Code
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#color/grey_10"
android:clipChildren="false"
tools:context="com.kurtihouse.nirzonpop.detailspage.view.ProductDetailsActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="256dp"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="#style/TextAppearance.AppCompat.Title"
app:layout_scrollFlags="scroll"
app:titleEnabled="false">
<ImageView
android:id="#+id/ivProductImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="fitXY"
android:src="#drawable/image_8"
app:layout_collapseMode="pin" />
<!--<android.support.v7.widget.RecyclerView
android:id="#+id/rvProductImage"
android:layout_width="match_parent"
android:layout_height="#dimen/product_image_height"
android:layout_marginEnd="1dp"
android:contentDescription="#string/image_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#mipmap/ic_launcher" />-->
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/overlay_dark_40" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStartWithNavigation="0dp"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</FrameLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:tint="#android:color/white"
app:srcCompat="#drawable/img_wizard_1" />
<!-- <View
android:layout_width="#dimen/spacing_middle"
android:layout_height="0dp" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nature Park"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Title"
android:textColor="#android:color/white" />-->
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-50dp"
android:clipToPadding="false"
android:scrollbars="vertical"
android:scrollingCache="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/cardView"
style="#style/CardViewTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_anchorGravity=""
app:layout_constraintTop_toBottomOf="#+id/rvProductImage">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_share_gray" />
<ImageView
android:id="#+id/ivFavorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="#+id/imageView2"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_favorite_off" />
<LinearLayout
android:id="#+id/llDirectContract"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="#color/colorBgSuccess"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvProductCode">
<ImageView
android:id="#+id/ivCall111"
android:layout_width="#dimen/iv_call_width"
android:layout_height="#dimen/iv_call_height"
android:paddingTop="5dp"
app:srcCompat="#drawable/ic_phone" />
<TextView
android:id="#+id/tvDirectContractNot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/padding_10"
android:text="#string/direct_buy"
android:textColor="#color/colorWhite"
android:textStyle="bold"
app:layout_constraintVertical_bias="0.0" />
</LinearLayout>
<TextView
android:id="#+id/tvPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text=""
android:textColor="#color/colorBlack"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageView2" />
<TextView
android:id="#+id/tvProductName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text=""
android:textColor="#color/colorBlack"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvPrice" />
<TextView
android:id="#+id/tvProductCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="swewewe"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvProductName" />
<TextView
android:id="#+id/tvAvailability"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:background="#drawable/border_toast_success"
android:paddingStart="10dp"
android:paddingTop="3dp"
android:paddingEnd="10dp"
android:paddingBottom="3dp"
android:text="TextView"
android:textColor="#color/colorWhite"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/llDirectContract"
app:layout_constraintStart_toEndOf="#+id/llDirectContract"
app:layout_constraintTop_toTopOf="#+id/llDirectContract" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/spacing_large" />
<android.support.v7.widget.CardView
android:id="#+id/sizeCardView"
style="#style/CardViewTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp">
<TextView
android:id="#+id/tvSize"
style="#style/Text.SizeSection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="#string/lbl_size" />
<TextView
android:id="#+id/tv_sizeList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="dlkfjldsfjkldsjf" />
</LinearLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/spacing_large" />
<android.support.v7.widget.CardView
android:id="#+id/detailsCardView"
style="#style/CardViewTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:paddingBottom="150dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/sizeCardView">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/descriptionLabel"
style="#style/Text.Description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Description"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:text="deesadefdsfdasfdsaf"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/descriptionLabel" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/spacing_large" />
<Button
android:id="#+id/btnAddCart"
android:layout_width="#dimen/btn_add_cart_width"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/round_button"
android:drawableStart="#drawable/ic_shopping_cart_white"
android:paddingStart="16dp"
android:text="#string/add_to_cart_label"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
This is happening because your appbarLayout have some elevation above the card view ! So use :-
app:elevation="0dp"
to your appBarLayout

Image not appear in Collapsing Toolbar

When first launch activity, the image not appear, but when u scroll, the image appear. I really confuse about this problem, please help. Is it because I'm using ConstraintLayout instead RecyclerView or LinearLayout?
Below is the XML code i use
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".InsideActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/collapsing_toolbar_appbarlayout"
android:layout_width="match_parent"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_height="200dp"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="#android:color/transparent"
android:fitsSystemWindows="true"
>
<ImageView
android:id="#+id/collapsing_toolbar_image_view"//this where i add image to toolbar
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar //this where the toolbar asign
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView //Im using to this, to make it scrollable
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView 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"
app:cardCornerRadius="4dp">
<com.facebook.shimmer.ShimmerFrameLayout // this to make shimmer effect when loading
android:id="#+id/shimmer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:shimmer_clip_to_children="true"
app:shimmer_direction="left_to_right"
app:shimmer_shape="linear"
android:layout_alignParentLeft="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="#layout/placeholder_inside_item"></include>
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
<android.support.constraint.ConstraintLayout 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/image_penulis"
android:layout_width="60dp"
android:layout_height="57dp"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="18dp"
android:src="#mipmap/ic_launcher_round"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/text_judul" />
<TextView
android:id="#+id/text_penulis"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="TextView"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/image_penulis"
app:layout_constraintTop_toBottomOf="#+id/text_judul"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/text_tanggal_tulis"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
android:textAppearance="#style/TextAppearance.AppCompat.Small"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/image_penulis"
app:layout_constraintTop_toBottomOf="#+id/text_penulis"
app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="#+id/image_thumbnail"
android:layout_width="0dp"
android:layout_height="200dp"
android:scaleType="fitXY"
app:layout_constraintBottom_toTopOf="#+id/text_judul"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintVertical_chainStyle="packed"
android:visibility="invisible"/>
<TextView
android:id="#+id/text_judul"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="24dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="TextView"
android:textAppearance="#android:style/TextAppearance.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/image_thumbnail" />
<TextView
android:id="#+id/text_isi_berita"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:text="TextView"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/image_penulis" />
<Button
android:id="#+id/btn_comment"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_marginBottom="24dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:background="#drawable/rounded_corner_button"
android:text="COMMENT"
android:textColor="#android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.51"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/text_isi_berita"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Below is the code in main activity :
Toolbar toolbar = (Toolbar)findViewById(R.id.collapsing_toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if(actionBar!=null)
{
// Display home menu item.
actionBar.setDisplayHomeAsUpEnabled(true);
}
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout)findViewById(R.id.collapsing_toolbar_layout);
collapsingToolbarLayout.setTitle("");
ImageView collapsingToolbarImageView = (ImageView)findViewById(R.id.collapsing_toolbar_image_view);
collapsingToolbarImageView.setImageResource(R.drawable.food);
I have followed all the solutions which could solve my problem, but the fact its not. Please help
Try this
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/collapsing_toolbar_appbarlayout"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="#android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/collapsing_toolbar_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/kid"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.CardView 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"
app:cardCornerRadius="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.facebook.shimmer.ShimmerFrameLayout
android:id="#+id/shimmer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:shimmer_clip_to_children="true"
app:shimmer_direction="left_to_right"
app:shimmer_shape="linear">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="#layout/placeholder_inside_item"></include>
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
<android.support.constraint.ConstraintLayout 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/image_penulis"
android:layout_width="60dp"
android:layout_height="57dp"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="18dp"
android:src="#mipmap/ic_launcher_round"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/text_judul" />
<TextView
android:id="#+id/text_penulis"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="TextView"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/image_penulis"
app:layout_constraintTop_toBottomOf="#+id/text_judul"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/text_tanggal_tulis"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
android:textAppearance="#style/TextAppearance.AppCompat.Small"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/image_penulis"
app:layout_constraintTop_toBottomOf="#+id/text_penulis"
app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="#+id/image_thumbnail"
android:layout_width="0dp"
android:layout_height="200dp"
android:scaleType="fitXY"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="#+id/text_judul"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="#+id/text_judul"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="24dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="TextView"
android:textAppearance="#android:style/TextAppearance.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/image_thumbnail" />
<TextView
android:id="#+id/text_isi_berita"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:text="TextView"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/image_penulis" />
<Button
android:id="#+id/btn_comment"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_marginBottom="24dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:background="#drawable/rounded_corner_button"
android:text="COMMENT"
android:textColor="#android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.51"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/text_isi_berita"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
</android.support.design.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.

Scrollable fragment in ConstraintLayout - 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>

Categories

Resources