I have an EditText that is not allowing to Focus and type. The screen has CoordinatorLayout as a root/parent and NestedScrollView with ViewPager.
On the TOP there WILL be google map and at the bottom there are two tabs.
First tab has text content with EDIT TEXT (which is having the issue) and on the second tab there is a recyclerview.
With this layout unable to Focus and Type on the EditText on the First Tab.
Parent Screen XML
<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"
tools:context="Fragments.JobOpen">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="#dimen/job_open_map_height"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimaryDark"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:titleEnabled="false">
<!--
TODO:: You may use fragment to load map just below the ImageView.
The ImageView is a placeholder I used during the design as a reference.
-->
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/gmap_screenshot"
app:layout_collapseMode="parallax"
android:contentDescription="#string/app_name" />
<!--
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7" />
-->
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/job_open_nested_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:focusableInTouchMode="true">
<android.support.design.widget.TabLayout
android:id="#+id/job_open_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="#dimen/archive_card_elevation"
android:background="#color/colorLightGray"
app:layout_constraintBottom_toTopOf="#+id/job_open_viewpager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintVertical_chainStyle="packed"
app:tabSelectedTextColor="#color/colorWhite"
app:tabTextColor="#color/colorFieldHint"
tools:targetApi="lollipop">
<!--
TODO:: Remove the tab items ...
I have kept it for your reference however it is useless here..
as loading from Viewpager class..
-->
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/job_details" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/services_providers" />
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="#+id/job_open_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/job_open_tab_layout" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Tab 1 XML
<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"
android:padding="#dimen/app_space"
tools:context="Fragments.JobOpenDetails">
<TextView
android:id="#+id/job_open_id_label"
style="#style/TextLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/app_space_one_half"
android:text="#string/job_id"
app:layout_constraintBottom_toTopOf="#+id/job_open_service_label"
app:layout_constraintEnd_toEndOf="#id/job_open_elapsed_time_label"
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/job_open_service_label"
style="#style/TextLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/app_space_one_half"
android:text="#string/problem"
app:layout_constraintBottom_toTopOf="#+id/job_open_elapsed_time_label"
app:layout_constraintEnd_toEndOf="#id/job_open_elapsed_time_label"
app:layout_constraintStart_toStartOf="#+id/job_open_id_label"
app:layout_constraintTop_toBottomOf="#+id/job_open_id_label" />
<TextView
android:id="#+id/job_open_elapsed_time_label"
style="#style/TextLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/app_space_one_half"
android:text="#string/elapsed_time"
app:layout_constraintBottom_toTopOf="#+id/job_open_time_label"
app:layout_constraintEnd_toStartOf="#id/job_open_content_barrier"
app:layout_constraintStart_toStartOf="#+id/job_open_id_label"
app:layout_constraintTop_toBottomOf="#+id/job_open_service_label" />
<TextView
android:id="#+id/job_open_time_label"
style="#style/TextLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/app_space_one_half"
android:text="Opened at"
app:layout_constraintBottom_toTopOf="#+id/job_open_vehicle_label"
app:layout_constraintEnd_toEndOf="#id/job_open_elapsed_time_label"
app:layout_constraintStart_toStartOf="#+id/job_open_id_label"
app:layout_constraintTop_toBottomOf="#+id/job_open_elapsed_time_label" />
<TextView
android:id="#+id/job_open_vehicle_label"
style="#style/TextLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/app_space_one_half"
android:text="#string/vehicle"
app:layout_constraintBottom_toTopOf="#+id/job_open_price_label"
app:layout_constraintEnd_toEndOf="#id/job_open_elapsed_time_label"
app:layout_constraintStart_toStartOf="#+id/job_open_id_label"
app:layout_constraintTop_toBottomOf="#+id/job_open_time_label" />
<TextView
android:id="#+id/job_open_price_label"
style="#style/TextLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/app_space_one_half"
android:text="#string/price"
app:layout_constraintBottom_toTopOf="#+id/job_open_note_label"
app:layout_constraintEnd_toEndOf="#id/job_open_elapsed_time_label"
app:layout_constraintStart_toStartOf="#+id/job_open_id_label"
app:layout_constraintTop_toBottomOf="#+id/job_open_vehicle_label" />
<TextView
android:id="#+id/job_open_note_label"
style="#style/TextLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/notes"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#id/job_open_elapsed_time_label"
app:layout_constraintStart_toStartOf="#+id/job_open_id_label"
app:layout_constraintTop_toBottomOf="#+id/job_open_price_label" />
<!-- separator -->
<android.support.constraint.Barrier
android:id="#+id/job_open_content_barrier"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:barrierDirection="right"
app:constraint_referenced_ids="job_open_note,job_open_time,job_open_id,job_open_vehicle,job_open_service,job_open_price,job_open_elapsed_time"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/job_open_id"
app:layout_constraintStart_toEndOf="#id/job_open_elapsed_time_label"
app:layout_constraintTop_toTopOf="parent" />
<!-- values -->
<TextView
android:id="#+id/job_open_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="345"
app:layout_constraintBaseline_toBaselineOf="#+id/job_open_id_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/job_open_content_barrier" />
<TextView
android:id="#+id/job_open_service"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="Flat Tire"
app:layout_constraintBaseline_toBaselineOf="#+id/job_open_service_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/job_open_id" />
<TextView
android:id="#+id/job_open_elapsed_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="5min"
app:layout_constraintBaseline_toBaselineOf="#+id/job_open_elapsed_time_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/job_open_id" />
<TextView
android:id="#+id/job_open_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="12:30pm on 12-31-2019"
app:layout_constraintBaseline_toBaselineOf="#+id/job_open_time_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/job_open_id" />
<TextView
android:id="#+id/job_open_vehicle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Nissan March K13 2013 Purple"
app:layout_constraintBaseline_toBaselineOf="#+id/job_open_vehicle_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/job_open_id" />
<TextView
android:id="#+id/job_open_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="$40"
app:layout_constraintBaseline_toBaselineOf="#+id/job_open_price_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/job_open_id" />
<TextView
android:id="#+id/job_open_note"
style="#style/TextContent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="I am waiting in a hotel just after highway. Please contact me as you arive on spot."
app:layout_constraintBottom_toTopOf="#id/job_open_action_barrier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/job_open_id"
app:layout_constraintTop_toTopOf="#+id/job_open_note_label"
app:layout_constraintVertical_bias="0.0" />
<android.support.constraint.Barrier
android:id="#+id/job_open_action_barrier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="job_open_note"
app:layout_constraintBottom_toTopOf="#+id/job_open_edit_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/job_open_note" />
<Button
android:id="#+id/job_open_edit_button"
style="#style/ButtonFlat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/app_space_one_half"
android:text="#string/edit"
app:layout_constraintStart_toStartOf="#+id/job_open_id_label"
app:layout_constraintTop_toBottomOf="#+id/job_open_action_barrier" />
<Button
android:id="#+id/job_open_cancel_button"
style="#style/ButtonPostTheme"
android:layout_marginTop="#dimen/app_space_one_half"
android:text="#string/cancel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/job_open_action_barrier" />
<EditText
android:id="#+id/test_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/job_open_cancel_button" />
</android.support.constraint.ConstraintLayout>
Tab 2 XML
<android.support.v4.widget.NestedScrollView 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:fillViewport="true"
tools:context="Fragments.JobOpenAppliedProviders">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/job_open_provider_sort_label"
style="#style/SortLabelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/app_space"
android:text="#string/sort_by"
app:layout_constraintBaseline_toBaselineOf="#+id/job_open_provider_sorty_time"
app:layout_constraintEnd_toStartOf="#+id/job_open_provider_sorty_time"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/job_open_provider_sorty_time"
style="#style/BodyMenuText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/time"
app:layout_constraintBaseline_toBaselineOf="#+id/job_open_provider_sort_distance"
app:layout_constraintEnd_toStartOf="#+id/job_open_sort_divider"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/job_open_provider_sort_label" />
<View
android:id="#+id/job_open_sort_divider"
android:layout_width="#dimen/job_open_provider_sort_divider_thickness"
android:layout_height="#dimen/job_open_provider_sort_divider_height"
android:layout_marginStart="#dimen/app_space_half"
android:layout_marginEnd="#dimen/app_space_half"
android:background="#color/colorListItemBorder"
app:layout_constraintBottom_toBottomOf="#+id/job_open_provider_sort_distance"
app:layout_constraintEnd_toStartOf="#+id/job_open_provider_sort_distance"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/job_open_provider_sorty_time"
app:layout_constraintTop_toTopOf="#+id/job_open_provider_sort_distance" />
<TextView
android:id="#+id/job_open_provider_sort_distance"
style="#style/BodyMenuText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/app_space"
android:layout_marginEnd="#dimen/app_space"
android:layout_marginBottom="#dimen/app_space_one_half"
android:text="#string/distance"
app:layout_constraintBottom_toTopOf="#id/job_open_provider_barrier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/job_open_sort_divider"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Barrier
android:id="#+id/job_open_provider_barrier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:layout_constraintBottom_toTopOf="#id/job_open_provider_list"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/job_open_provider_sort_distance" />
<android.support.v7.widget.RecyclerView
android:id="#+id/job_open_provider_list"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/job_open_provider_barrier" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
You can force the edit text to gain focus programmatically. Inside your TAB1 java class you can do the following that will force the edit text to gain focus.
EditText editText = findViewById(R.id.test_text); //initialize edit text
editText.requestFocus(); //will request focus
//will force the keyboard to show
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
Related
I created a ScrollView inside a BottomSheet and yes, it scrolls down properly but when it stops and I try to scroll up, the BottomSheet instead collapses. But when I scroll down first before scrolling up, it actually scrolls up properly. I don't want my users to feel the need to scroll down first before actually scrolling up because this can cause user frustration.
Here is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drawer_layout"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.fragment.app.FragmentContainerView
android:id="#+id/mapsRoute"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/menu_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="40dp"
android:onClick="ClickMenu"
android:src="#drawable/ic_baseline_menu_24"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="#000000" />
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="TIP: To scroll back up the route viewer, swipe up first then swipe down."
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="10dp"
android:layout_marginBottom="65dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFFFFF"
>
<include layout="#layout/navigation_toolbar" />
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
<FrameLayout
android:id="#+id/routesContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
android:background="#drawable/bottomtoolbar"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:paddingTop="5dp"
android:paddingBottom="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
>
<ImageView
android:id="#+id/baselineRouteViewer"
android:layout_width="60dp"
android:layout_height="8dp"
android:src="#drawable/ic_baseline"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="15dp"
/>
<TextView
android:id="#+id/routesText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VIEW ROUTES & TERMINALS"
android:fontFamily="#font/assistantextrabold"
android:textColor="#color/secondary"
android:textSize="25sp"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
app:layout_constraintTop_toBottomOf="#+id/baselineRouteViewer"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
<com.google.android.material.tabs.TabLayout
android:id="#+id/routeTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/primary"
app:tabSelectedTextColor="#color/secondary"
app:tabTextColor="#color/custom3"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#id/routesText"
app:layout_constraintRight_toRightOf="parent">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUS ROUTES"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="JEEP ROUTES"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TERMINALS"/>
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/routeViewPager"
android:layout_width="match_parent"
android:layout_height="220dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/routeTabs"
/>
<Button
android:id="#+id/clearMap"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Clear Map"
android:textSize="10sp"
android:fontFamily="#font/assistantextrabold"
app:layout_constraintTop_toBottomOf="#+id/routeViewPager"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:backgroundTint="#color/secondary"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
My app bar is located below my scroll view and therefore the items are not clickable
My scroll view should stop just above my BottomAppBar
how to do that ?
And how to make the BottomAppBar always visible
Useless text for my post to pass, very restrictive this rule
The story of a cat who wanted to eat the dog's bowl.
I hope there is enough unnecessary text
Layout
<?xml version="1.0" encoding="utf-8"?>
<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"
android:fitsSystemWindows="true">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
style="#style/Widget.MaterialComponents.BottomAppBar.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:menu="#menu/menu_show_bottom"
app:navigationIcon="#drawable/ic_action_home_blank" />
<include
android:id="#+id/contentScroll"
layout="#layout/content_scrolling" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/btnAddClean"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bottomAppBar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="#drawable/ic_action_clean" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Content scrolled
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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:showIn="#layout/fragment_avaloir_show">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/rueTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Rue des jolis bois " />
<ImageView
android:id="#+id/avaloirImageView"
android:layout_width="263dp"
android:layout_height="350dp"
android:contentDescription="#string/content_description"
android:src="#drawable/aval2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rueTextView" />
<TextView
android:id="#+id/coordinatesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/avaloirImageView"
tools:text="50.235621, 5.23658" />
<com.google.android.gms.maps.MapView
android:id="#+id/mapView"
android:layout_width="match_parent"
android:layout_height="350dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/coordinatesTextView" />
<TextView
android:id="#+id/titreDatesNettoyageTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="#string/title_dates_nettoyage"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mapView" />
<View
android:id="#+id/dividerView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="#+id/titreDatesNettoyageTextView" />
<TextView
android:id="#+id/datesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dividerView"
tools:text="10 avril 2019" />
<TextView
android:id="#+id/titreCommentairesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="#string/title_commentaires"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/datesTextView" />
<View
android:id="#+id/commentDividerView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="#+id/titreCommentairesTextView" />
<TextView
android:id="#+id/commentairesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/commentDividerView"
tools:text="Il est cassé il faut le remplacer" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
finally I added a linearLayout
<?xml version="1.0" encoding="utf-8"?>
<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">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="#+id/contentScroll"
layout="#layout/content_scrolling" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
style="#style/Widget.MaterialComponents.BottomAppBar.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:menu="#menu/menu_show_bottom"
app:navigationIcon="#drawable/ic_action_home_blank" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/btnAddClean"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bottomAppBar"
app:srcCompat="#drawable/ic_action_clean" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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">
<TextView
android:id="#+id/rueTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Rue des jolis bois " />
<ImageView
android:id="#+id/avaloirImageView"
android:layout_width="263dp"
android:layout_height="350dp"
android:contentDescription="#string/content_description"
android:src="#drawable/aval2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rueTextView" />
<TextView
android:id="#+id/coordinatesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/avaloirImageView"
tools:text="50.235621, 5.23658" />
<com.google.android.gms.maps.MapView
android:id="#+id/mapView"
android:layout_width="match_parent"
android:layout_height="350dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/coordinatesTextView" />
<TextView
android:id="#+id/titreDatesNettoyageTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="#string/title_dates_nettoyage"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mapView" />
<View
android:id="#+id/dividerView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="#+id/titreDatesNettoyageTextView" />
<TextView
android:id="#+id/datesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dividerView"
tools:text="10 avril 2019" />
<TextView
android:id="#+id/titreCommentairesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="#string/title_commentaires"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/datesTextView" />
<View
android:id="#+id/commentDividerView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="#+id/titreCommentairesTextView" />
<TextView
android:id="#+id/commentairesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/commentDividerView"
tools:text="Il est cassé il faut le remplacer" />
</androidx.constraintlayout.widget.ConstraintLayout>
I have an activity layout that consists of:
A sticky non-collapsing Toolbar on the top of the page
A NestedScrollView that contains two headers for two RecyclerViews
A ConstraintLayout to position the items inside NestedScrollView
Two RecyclerViews
The XML file is below:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:fillViewport="true">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
app:layout_scrollFlags="enterAlways"
app:popupTheme="#style/Theme.AppCompat.Light">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/backButton"
style="#style/Icon"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_2" />
<View
android:id="#+id/view13"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/bg_white_ellipse_with_border"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/backButton"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/imageView21"
style="#style/Icon"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="#+id/view13"
app:layout_constraintStart_toStartOf="#+id/view13"
app:layout_constraintTop_toTopOf="#+id/view13"
app:srcCompat="#drawable/ic_1" />
<EditText
android:id="#+id/searchField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:background="#color/fui_transparent"
android:ems="10"
android:hint="Type something"
android:imeOptions="actionSearch"
android:inputType="text"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="#+id/view13"
app:layout_constraintStart_toEndOf="#+id/imageView21"
app:layout_constraintTop_toTopOf="#+id/view13" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="#+id/view8"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#color/colorLightGray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="#+id/view9"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#color/colorLightGray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rv1" />
<View
android:id="#+id/view12"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginBottom="16dp"
android:background="#color/colorLightGray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rv2" />
<TextView
android:id="#+id/textView21"
style="#style/HeadingText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Dishes"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view8" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView21" />
<TextView
android:id="#+id/textView8"
style="#style/HeadingText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Restaurants"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view9" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/view12"
app:layout_constraintTop_toBottomOf="#+id/textView8" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
The toolbar is fixed at the top of the page as I wanted. Everything scrolls correctly. However, I can't scroll until the end of the NestedScrollView, i.e. the item was cut off and I cannot scroll to the last item in the second RecyclerView. How do I fix this?
For some reason, this attribute android:fillViewport="true" on CoordinatorLayout caused it to break. Removing that attribute corrects everything.
I'm having some trouble with a partly hidden RecyclerView on the small devices below 5.5" (Nexus, A3, etc...)
Once the feed's loaded, and added to the adapter items, all the children of the CoordinatorLayout moved up.
You can see the demo here
Here's the hierarchy of the view:
CoordinatorLayout
AppBarLayout
LiveCollapsingToolbarLayout
CardView
ConstraintLayout
SmoothRecyclerView
And here the main layout:
<?xml version="1.0" encoding="utf-8"?>
<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/live_main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/home_header_height_reduced"
android:fitsSystemWindows="true">
<com.radiofrance.radio.francebleu.android.view.toolbar.LiveCollapsingToolbarLayout
android:id="#+id/live_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:contentScrim="#color/bleu_primary"
app:expandedTitleTextAppearance="#android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:importantForAccessibility="noHideDescendants"
app:layout_collapseMode="parallax">
<ImageView
android:id="#+id/live_weather_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="#+id/live_date"
style="#style/HomeDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/live_ephemeris"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintVertical_bias="0.6"
tools:text="#tools:sample/date/day_of_week" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="#+id/live_ephemeris"
style="#style/HomeEphemeride"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/live_weather"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/live_date"
app:layout_constraintVertical_bias="1.0"
tools:text="St Guy" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="#+id/live_weather"
style="#style/HomeTemperature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/live_ephemeris"
app:layout_constraintVertical_bias="0.7"
tools:text="14°" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin">
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="#+id/live_toolbar_title"
style="#style/TextHomeToolbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textColor="#color/white" />
</androidx.appcompat.widget.Toolbar>
</com.radiofrance.radio.francebleu.android.view.toolbar.LiveCollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.cardview.widget.CardView
android:id="#+id/live_card_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/home_live_card_horizontal_margin"
android:layout_marginEnd="#dimen/home_live_card_horizontal_margin"
app:behavior_overlapTop="48dp"
app:cardElevation="3.8dp"
app:cardPreventCornerOverlap="#bool/card_overlap"
app:cardUseCompatPadding="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/live_card_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAccessibility="yes">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/live_card_cover"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="h,16:9"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#color/translucent"
app:layout_constraintBottom_toBottomOf="#id/live_card_cover"
app:layout_constraintLeft_toLeftOf="#id/live_card_cover"
app:layout_constraintRight_toRightOf="#id/live_card_cover"
app:layout_constraintTop_toTopOf="#id/live_card_cover" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
style="#style/TextHomeLiveStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/horizontal_margin"
android:layout_marginTop="14dp"
android:text="#string/home_live_status"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="#+id/live_card_player_debug"
style="#style/TextHomeLiveStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginEnd="#dimen/horizontal_margin"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Player debug" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="#+id/live_card_title"
style="#style/TextHomeLiveTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/horizontal_margin"
android:ellipsize="end"
android:maxLines="3"
app:layout_constraintBottom_toBottomOf="#+id/live_card_cover"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#id/live_card_player"
tools:text="Live de France Bleu" />
<com.radiofrance.radio.francebleu.android.view.progress.ProgressCircleImageView
android:id="#+id/live_card_player"
android:layout_width="#dimen/home_play_button_size"
android:layout_height="#dimen/home_play_button_size"
android:layout_marginEnd="#dimen/horizontal_margin"
android:layout_marginBottom="#dimen/horizontal_margin"
android:clickable="true"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="#+id/live_card_cover"
app:layout_constraintRight_toRightOf="parent"
app:pciv_background="#drawable/bg_play_dark"
app:pciv_padding="12dp"
app:pciv_progressBackground="#drawable/bg_play_progress_dark"
app:pciv_progressColor="#color/bleu_primary"
app:pciv_src="#drawable/eavd_vd_play" />
<LinearLayout
android:id="#+id/live_card_cover_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="#dimen/horizontal_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/live_card_cover">
<TextView
style="#style/HomeLiveTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:ellipsize="end"
android:lines="2"
android:text="#string/home_call_description" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="#+id/live_card_call"
style="#style/TextRobotoBold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/home_call_action"
android:text="#string/home_call_action"
android:textAllCaps="true"
android:textColor="#color/bleu_accent" />
</LinearLayout>
<com.radiofrance.radio.francebleu.android.view.error.GenericErrorView
android:id="#+id/live_card_error"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#color/white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<com.radiofrance.radio.francebleu.android.view.scroll.SmoothRecyclerView
android:id="#+id/live_feed_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_overlapTop="48dp"
android:accessibilityTraversalAfter="#id/live_card_layout"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<include layout="#layout/card_see_new_actualities" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
[Update]
It seems the problem comes from the horizontal recyclerview that is in live_feed_recyclerview as a ViewHolder
What I want to achieve is that the cardview is also scrolled up, when the recyclerview (In my xml it's just framelayout but I will later replace it) is scrolled. It is easier to understand with the 2 pictures below.
Not Scrolled
After Scrolling
As you can see from the second picture, the user profile cardview lingers, while I expect it to be scrolled up.
Another problem is that between toolbar and the cardview, there is an empty space line, which you can see in the first picture. I don't know how to remove that.
And the toolbar is also not showing the title, which is set programmatically. No idea why.
This is the xml file. Thanks in advance!
<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:layout_margin="0dp"
android:fitsSystemWindows="true"
app:statusBarBackground="#android:color/transparent">
<android.support.design.widget.AppBarLayout
android:id="#+id/up_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:layout_marginBottom="0dp"
android:elevation="4dp"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/up_ctoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:collapsedTitleGravity="center"
app:contentScrim="#android:color/transparent"
app:expandedTitleGravity="center"
app:layout_behavior="#string/title_activity_scrolling"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="true"
app:toolbarId="#+id/up_toolbar">
<ImageView
android:id="#+id/up_header"
android:layout_width="match_parent"
android:layout_height="#dimen/header_height"
android:background="#drawable/nav_background"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/up_toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/button_size"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/up_back"
android:layout_width="#dimen/button_size"
android:layout_height="#dimen/button_size"
android:background="#android:color/transparent"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_back_white" />
<ImageButton
android:id="#+id/up_search"
android:layout_width="#dimen/button_size"
android:layout_height="#dimen/button_size"
android:background="#android:color/transparent"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_search_white" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
</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:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:layout_marginBottom="16dp"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/up_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="0dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/up_usericon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:clickable="true"
android:src="#android:drawable/sym_def_app_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/up_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:maxLines="1"
android:text="Username"
android:textColor="#color/BlackGray"
android:textSize="19sp"
app:layout_constraintStart_toStartOf="#+id/up_usericon"
app:layout_constraintTop_toBottomOf="#+id/up_usericon" />
<TextView
android:id="#+id/up_user_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#10000000"
app:layout_constraintStart_toStartOf="#+id/up_username"
app:layout_constraintTop_toBottomOf="#+id/up_username" />
<TextView
android:id="#+id/up_intro"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:text="Intro: "
android:textColor="#color/BlackGray"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/up_user_number"
app:layout_constraintTop_toBottomOf="#+id/up_user_number" />
<TextView
android:id="#+id/up_followers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="28dp"
android:clickable="true"
android:text="Followers: 0"
app:layout_constraintBottom_toBottomOf="#+id/up_following"
app:layout_constraintStart_toEndOf="#+id/up_following" />
<TextView
android:id="#+id/up_following"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:clickable="true"
android:text="Following: 0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#+id/up_intro"
app:layout_constraintTop_toBottomOf="#+id/up_intro" />
<ImageButton
android:id="#+id/up_message"
android:layout_width="#dimen/button_size"
android:layout_height="#dimen/button_size_small"
android:layout_marginEnd="16dp"
android:background="#drawable/button_border_green"
app:layout_constraintEnd_toStartOf="#+id/up_follow"
app:layout_constraintTop_toTopOf="#+id/up_follow"
app:srcCompat="#drawable/ic_mail" />
<ImageButton
android:id="#+id/up_follow"
android:layout_width="#dimen/button_size"
android:layout_height="#dimen/button_size_small"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:background="#drawable/button_border_orange"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_follow" />
<ImageButton
android:id="#+id/up_edit"
android:layout_width="#dimen/button_size"
android:layout_height="#dimen/button_size_small"
android:layout_marginEnd="16dp"
android:background="#drawable/button_border_orange"
app:layout_constraintEnd_toStartOf="#+id/up_message"
app:layout_constraintTop_toTopOf="#+id/up_message"
app:srcCompat="#drawable/ic_edit" />
<ImageView
android:id="#+id/up_gender"
android:layout_width="#dimen/icon_size_small"
android:layout_height="#dimen/icon_size_small"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="#+id/up_user_number"
app:layout_constraintStart_toEndOf="#+id/up_user_number"
app:layout_constraintTop_toTopOf="#+id/up_user_number"
app:srcCompat="#drawable/ic_male" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<android.support.constraint.ConstraintLayout
android:id="#+id/posts_sort_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TextView
android:id="#+id/up_posts"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
android:text="Posts: 0"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="#+id/up_sortby_button"
style="#style/Widget.AppCompat.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="#android:color/transparent"
android:drawableRight="#drawable/ic_down_blue"
android:text="#string/sort_by"
android:textAllCaps="false"
android:textColor="#color/design_default_color_primary"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
<FrameLayout
android:id="#+id/up_timeline"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>