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>
Related
I have activity with horizontal scroll view to display four button's. Below located FrameLayout witch display fragment based on what button was clicked. Second and Fourth button shows RecyclerView with a lot of data. How can i make this horizontal scroll view to stay on top below or in place of Toolbar, so i can switch between fragments withount going all the way up?
<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="match_parent"
android:background="#color/smoky_white"
android:orientation="vertical"
tools:context=".o_kaznau">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/purple_200"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:title="О КазНАИУ" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar"
app:layout_constraintVertical_bias="1.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView11"
android:layout_width="match_parent"
android:layout_height="230dp"
android:scaleType="fitXY"
android:src="#drawable/im_maincorpus1"/>
<HorizontalScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="#+id/btnAbout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/about_btn"
android:onClick="aboutAbout"
android:textSize="15sp"
android:textAllCaps="false"
android:text="Об университете" />
<Button
android:id="#+id/btnRyk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/about_btn"
android:onClick="aboutRyc"
android:textSize="15sp"
android:textAllCaps="false"
android:text="Руководство" />
<Button
android:id="#+id/btnPolitika"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/about_btn"
android:onClick="aboutPolitika"
android:textSize="15sp"
android:textAllCaps="false"
android:text="Политика" />
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/about_btn"
android:onClick="aboutYstav"
android:textSize="15sp"
android:textAllCaps="false"
android:text="Устав" />
</LinearLayout>
</HorizontalScrollView>
<FrameLayout
android:id="#+id/aboutFL"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
I have a question about my Android App. I have a menu with different options. For the home button, I use a fragment, in which I want to scroll. First time, I added ScrollView in the fragment xml, but it didn't work at all. Then, I tried ScrollView in the main activity with the menu, but it didn't work.
Here is the main activity xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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"
android:isScrollContainer="false">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MainActivity">
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/bottomAppBar" />
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="#color/green_700"
app:fabAlignmentMode="center"
app:fabCradleMargin="10dp"
app:fabCradleRoundedCornerRadius="30dp"
app:fabCradleVerticalOffset="10dp"
app:contentInsetStart="0dp">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:itemIconTint="#color/light_grey"
app:itemTextColor="#color/light_grey"
app:itemTextAppearanceActive="#font/josefin_sans_semibold"
android:background="#drawable/background_transparent"
app:menu="#menu/bottom_navigation_menu" />
</com.google.android.material.bottomappbar.BottomAppBar>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onPressFab"
android:src="#drawable/ic_add"
app:layout_anchor="#id/bottomAppBar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</ScrollView>
And here is the fragment xml:
<?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="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/myCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
app:layout_constraintTop_toTopOf="parent">
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.card.MaterialCardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="100dp"
app:cardBackgroundColor="#color/green_700"
app:cardElevation="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.428"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="#style/ShapeAppearanceOverlay.MaterialCardView.Cut">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="30dp"
android:layout_marginRight="30dp"
android:background="#drawable/search_outline"
android:fontFamily="#font/josefin_sans_semibold"
android:hint="Search Barcode"
android:inputType="text"
android:maxLines="1"
android:paddingLeft="30dp"
android:paddingTop="10dp"
android:paddingRight="30dp"
android:paddingBottom="10dp"
android:textColor="#color/dark_grey"
android:textColorHint="#color/grey_200"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.183"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/sbutton"
android:layout_width="90dp"
android:layout_height="60dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="16dp"
android:background="#drawable/background_transparent"
android:drawableLeft="#drawable/search_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<ImageView
android:id="#+id/imageView4"
android:layout_width="450dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="64dp"
android:layout_marginRight="64dp"
android:src="#drawable/home_image"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView3"
android:layout_width="208dp"
android:layout_height="138dp"
android:layout_marginTop="120dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:gravity="center"
android:text="Welcome back!"
android:textColor="#color/darker_grey"
android:textSize="40sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/myCoordinatorLayout" />
<androidx.viewpager.widget.ViewPager
android:id="#+id/viewPager"
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginTop="340dp"
android:clipToPadding="false"
android:foregroundGravity="center"
android:overScrollMode="never"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.16"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/myCoordinatorLayout">
</androidx.viewpager.widget.ViewPager>
</androidx.constraintlayout.widget.ConstraintLayout>
I would be greatful if you have any suggestions. Thank you!
I am not sure if I understood your use case correctly but if you want your fragment to be scrollable then use scrollview inside your fragment layout and make sure android:isScrollContainer is set to true.
What is the best way to achieve the following UI where I want a button to appear "outside" and above a TextView?
Here's what I want to do (expected), the code I've written for it, and how it appears in my emulator (actual).
Expected: the "x" button is outside of the text view
My Layout:
(also, note: I'm inflating the bottom_sheet_layout in a class that extends com.google.android.material.bottomsheet.BottomSheetDialogFragment)
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/bottom_sheet_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/blue">
<TextView
android:id="#+id/bottom_sheet_menu_delete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Delete"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="#+id/bottom_sheet_x"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="#drawable/ic_cancel_24dp"
app:layout_constraintBottom_toTopOf="#id/bottom_sheet_menu_delete"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Actual:
change the layout_constraintBottom_toTopOf id of Button
move background from parent to TextView
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/bottom_sheet_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<TextView
android:id="#+id/bottom_sheet_menu_delete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="#color/blue"//add background
android:text="Delete"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="#+id/bottom_sheet_x"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="#drawable/ic_cancel_24dp"
app:layout_constraintBottom_toTopOf="#id/bottom_sheet_menu_delete"//change id
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/bottom_sheet_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/blue">
<Button
android:id="#+id/bottom_sheet_x"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="#drawable/ic_cancel_24dp"
app:layout_constraintBottom_toTopOf="#+id/bottom_sheet_menu_delete"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="#+id/bottom_sheet_menu_delete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Delete"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
try this -->
<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:id="#+id/bottom_sheet_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<Button
android:id="#+id/bottom_sheet_x"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="#drawable/your_cross_image"
app:layout_constraintEnd_toEndOf="parent"
tools:ignore="MissingConstraints" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent"
app:layout_constraintTop_toBottomOf="#id/bottom_sheet_x"
tools:ignore="MissingConstraints,NotSibling">
<TextView
android:id="#+id/bottom_sheet_menu_delete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Delete"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
I have an activity that contains one fragment added by the include tag (at the top of the activity) and one main central fragment. The main fragment also contains the editText widget. When I click on the edittext keyboard it is displayed and based on the window chosen, the SoftInputMode keyboard moves the window upwards (the upper fragment disappears behind the screen) or overlaps the buttons below the keyboard on the main fragment. (scrolling does not appear in both cases).
I need scrollable fragment window, but its impossible? How?
Xmls:
Activity:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:background="?attr/bg_second"
android:keepScreenOn="true">
<FrameLayout
android:id="#+id/fl_work_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|right|end"
tools:ignore="RtlHardcoded" />
<include layout="#layout/view_menu_main" />
Main fragment:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="#id/tv_tariff_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/textInputLayout">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/space_large_m"
android:background="?attr/bg_main"
android:minHeight="120dp"
android:paddingStart="#dimen/space_medium_xl"
android:paddingTop="#dimen/space_medium_l"
android:paddingEnd="#dimen/space_medium_xl" />
<TextView
android:id="#+id/tv_empty_point"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/space_medium_s"
android:text="#string/road_to_empty_text"
android:textAlignment="center"
android:textColor="?attr/text_main"
tools:textColor="#color/black" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/space_medium_xl"
android:tint="#android:color/white"
app:backgroundTint="#color/bg_button_light"
app:layout_anchor="#id/rv_border"
app:layout_anchorGravity="bottom|right|end"
app:srcCompat="#android:drawable/ic_input_add" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:paddingStart="#dimen/space_small_l"
android:paddingEnd="#dimen/space_small_l"
android:theme="#style/TextInputLayout"
app:layout_constraintBottom_toTopOf="#id/tv_tariff_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="+7949919">
<EditText
android:id="#+id/phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/phone_number_of_client"
android:importantForAutofill="no"
android:inputType="phone"
android:maxLength="15"
android:maxLines="1"
android:singleLine="true"
android:textColor="?attr/text_main"
android:textColorHighlight="#android:color/darker_gray"
android:textColorHint="#android:color/darker_gray"
tools:textColor="#color/black" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/tv_tariff_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:padding="#dimen/space_medium_s"
android:singleLine="true"
android:text="#string/work_main_tariff"
android:textColor="?attr/text_main"
android:textSize="#dimen/font_size_huge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/textInputLayout"
tools:textColor="#color/black" />
<LinearLayout
android:id="#+id/ll_tariff_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_second"
android:orientation="horizontal"
android:weightSum="3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/tv_tariff_label">
<TextView
android:id="#+id/tv_tariff"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.8"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:paddingStart="#dimen/space_medium_s"
android:paddingEnd="#dimen/space_medium_s"
android:tag="tariff"
android:textColor="?attr/text_main"
android:textSize="#dimen/font_size_huge"
tools:text="My tariff"
tools:textColor="#color/black" />
<Button
android:id="#+id/add_opt_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:background="#drawable/custom_button_green"
android:text="#string/options_title"
android:textColor="?attr/text_button"
android:textSize="#dimen/font_size_large"
android:visibility="invisible"
tools:textColor="#color/white" />
<ProgressBar
android:id="#+id/p_bar_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="4dp"
android:layout_weight="1.2"
android:padding="4dp"
android:text="#string/options_title"
android:textColor="?attr/text_button"
android:textSize="#dimen/font_size_large"
android:theme="#style/accentStyle"
android:visibility="gone"
tools:textColor="#color/white" />
</LinearLayout>
<Button
android:id="#+id/btn_start_work"
android:layout_width="wrap_content"
android:layout_height="#dimen/button_height"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
android:background="#drawable/custom_button_green"
android:text="#string/work_btn_begin"
android:textColor="?attr/text_button"
android:textSize="#dimen/font_size_large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ll_tariff_view"
tools:textColor="#color/white" />
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:theme="#style/accentStyle"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ll_tariff_view"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
You can use below code into Manifest file for your activity, I think it should resolve your problem
android:windowSoftInputMode="adjustPan|adjustResize"
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>