How to add scrollview to this
<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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="0dp"
android:layout_height="143dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="#+id/imageButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:srcCompat="#drawable/warmbanner" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardView2"
android:layout_width="0dp"
android:layout_height="169dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView">
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
app:srcCompat="#drawable/chestday" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardView3"
android:layout_width="0dp"
android:layout_height="108dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView2">
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
app:srcCompat="#drawable/sh" />
</android.support.v7.widget.CardView>
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="49dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:menu="#menu/navigation">
</android.support.design.widget.BottomNavigationView>
</android.support.constraint.ConstraintLayout>
Solution:
Just paste this code inside your parent top-level ConstraintLayout and try:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true">
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="0dp"
android:layout_height="143dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="#+id/imageButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:srcCompat="#mipmap/ic_launcher" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardView2"
android:layout_width="0dp"
android:layout_height="169dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView">
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
app:srcCompat="#mipmap/ic_launcher" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardView3"
android:layout_width="0dp"
android:layout_height="108dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView2">
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
app:srcCompat="#mipmap/ic_launcher" />
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="#menu/navigation">
</android.support.design.widget.BottomNavigationView>
Hope it helps.
See the below code:
<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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
(Write Here)
</android.support.constraint.ConstraintLayout>
Related
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
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>
in my project when i put constraint layout in scrollview not scroll and constraintlayout is fixed.
this is my xml 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"
xmlns:williamchart="http://schemas.android.com/apk/res-auto">
<data>
</data>
<androidx.drawerlayout.widget.DrawerLayout
android:id="#+id/mdrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="right"
android:layoutDirection="rtl">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back">
<androidx.appcompat.widget.Toolbar
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.77"
android:background="#12315C"
android:gravity="right"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/hammenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:paddingTop="6dp"
android:src="#drawable/hammenu" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:foregroundGravity="center_vertical|center|center_horizontal"
android:gravity="center|center_horizontal|center_vertical"
android:text="بازارها"
android:textColor="#android:color/background_light"
android:textSize="18dp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
<ScrollView
android:id="#+id/scroll"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:fillViewport="true"
android:isScrollContainer="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/app_bar"
williamchart:layout_constraintEnd_toEndOf="parent"
williamchart:layout_constraintStart_toStartOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:isScrollContainer="true"
android:nestedScrollingEnabled="true"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialcardview8"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
williamchart:cardBackgroundColor="#android:color/transparent"
williamchart:cardCornerRadius="32dp"
williamchart:layout_constraintHeight_percent="0.25"
williamchart:layout_constraintTop_toBottomOf="#+id/materialcardview6"
williamchart:layout_constraintWidth_percent="0.4">
<io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
android:id="#+id/blurLayout7"
android:layout_width="match_parent"
android:layout_height="match_parent"
blurkit:blk_downscaleFactor="0.30"
blurkit:blk_fps="0" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView7"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:elevation="4dp"
williamchart:layout_constraintBottom_toBottomOf="parent"
williamchart:layout_constraintDimensionRatio="h,15:9"
williamchart:layout_constraintEnd_toEndOf="parent"
williamchart:layout_constraintStart_toStartOf="parent"
williamchart:layout_constraintTop_toTopOf="parent"
williamchart:srcCompat="#drawable/mypardis" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialcardview6"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
williamchart:cardBackgroundColor="#android:color/transparent"
williamchart:cardCornerRadius="32dp"
williamchart:layout_constraintHeight_percent="0.25"
williamchart:layout_constraintTop_toBottomOf="#+id/materialcardview4"
williamchart:layout_constraintWidth_percent="0.4">
<io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
android:id="#+id/blurLayout5"
android:layout_width="match_parent"
android:layout_height="match_parent"
blurkit:blk_downscaleFactor="0.30"
blurkit:blk_fps="0" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView5"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:elevation="4dp"
williamchart:layout_constraintBottom_toBottomOf="parent"
williamchart:layout_constraintDimensionRatio="h,15:9"
williamchart:layout_constraintEnd_toEndOf="parent"
williamchart:layout_constraintStart_toStartOf="parent"
williamchart:layout_constraintTop_toTopOf="parent"
williamchart:srcCompat="#drawable/mypardis" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialcardview4"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
williamchart:cardBackgroundColor="#android:color/transparent"
williamchart:cardCornerRadius="32dp"
williamchart:layout_constraintHeight_percent="0.25"
williamchart:layout_constraintTop_toBottomOf="#+id/materialcardview2"
williamchart:layout_constraintWidth_percent="0.4">
<io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
android:id="#+id/blurLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
blurkit:blk_downscaleFactor="0.30"
blurkit:blk_fps="0" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView3"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:elevation="4dp"
williamchart:layout_constraintBottom_toBottomOf="parent"
williamchart:layout_constraintDimensionRatio="h,15:9"
williamchart:layout_constraintEnd_toEndOf="parent"
williamchart:layout_constraintStart_toStartOf="parent"
williamchart:layout_constraintTop_toTopOf="parent"
williamchart:srcCompat="#drawable/mypardis" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialcardview2"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
williamchart:cardBackgroundColor="#android:color/transparent"
williamchart:cardCornerRadius="32dp"
williamchart:layout_constraintHeight_percent="0.25"
williamchart:layout_constraintTop_toTopOf="parent"
williamchart:layout_constraintWidth_percent="0.4">
<io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
android:id="#+id/blurLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
blurkit:blk_downscaleFactor="0.30"
blurkit:blk_fps="0" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:elevation="4dp"
williamchart:layout_constraintBottom_toBottomOf="parent"
williamchart:layout_constraintDimensionRatio="h,15:9"
williamchart:layout_constraintEnd_toEndOf="parent"
williamchart:layout_constraintStart_toStartOf="parent"
williamchart:layout_constraintTop_toTopOf="parent"
williamchart:srcCompat="#drawable/mypardis" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialCardView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
app:cardBackgroundColor="#android:color/transparent"
app:cardCornerRadius="32dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.25"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.4">
<io.alterac.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
android:id="#+id/blurLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
blurkit:blk_downscaleFactor="0.30"
blurkit:blk_fps="0" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView2"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:elevation="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="h,15:9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
williamchart:srcCompat="#drawable/mypardis" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right" />
<!--app:headerLayout="#layout/navigation_header"
app:menu="#menu/drawermenu"-->
</androidx.drawerlayout.widget.DrawerLayout>
</layout>
but when i convert constraint to linear it's work good.
i search many topic and put android:fillViewport="true" in scroll view but yet my constraintlayout not scroll
if i put scrollview as root view that's ok
use NestedScrollView with viewport true
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="700dp">
</android.support.constraint.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
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>
The image of what I need to acheive:
I have two FloatingActionButtons,
One constrainted to the left of the parent,
The other to the right,
How to alter the following layout to achieve:
Having 2 TextViews, both engagin all width available between buttons, and half of the height available, sitting on top of each other?
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="#color/colorPrimary"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:fabSize="mini"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_edit_w"
tools:layout_editor_absoluteX="41dp"
tools:layout_editor_absoluteY="16dp" />
<TextView
android:id="#+id/txt_top"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/fab_edit"
android:text="top"/>
<TextView
android:id="#+id/txt_btm"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/fab_play"
android:text="bottom"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_play"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:fabSize="mini"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
app:srcCompat="#drawable/ic_play_w"
tools:layout_editor_absoluteX="220dp"
tools:layout_editor_absoluteY="8dp" />
</android.support.constraint.ConstraintLayout>
Try the following:
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="#color/colorPrimary"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:fabSize="mini"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="41dp"
tools:layout_editor_absoluteY="16dp" />
<TextView
android:id="#+id/txt_top"
android:layout_width="0dp"
android:layout_height="match_parent"
android:padding="8dp"
android:gravity="center"
app:layout_constraintBottom_toTopOf="#id/txt_btm"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="#id/fab_edit"
app:layout_constraintEnd_toStartOf="#id/fab_play"
android:text="top"/>
<TextView
android:id="#+id/txt_btm"
android:layout_width="0dp"
android:layout_height="match_parent"
android:padding="8dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="#id/txt_top"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/fab_edit"
app:layout_constraintEnd_toStartOf="#id/fab_play"
android:text="bottom"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_play"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:fabSize="mini"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
tools:layout_editor_absoluteX="220dp"
tools:layout_editor_absoluteY="8dp" />
</android.support.constraint.ConstraintLayout>