0

I need to scroll all the view not only a list view. It's only listview scrolling I need to scroll with header Screenshot. How to do it? I tried NestedScroll but it doesn't work for me. It worked when I set fixed height but I don't know the final size of the list. Is it possible to fix it using the only XML without java?

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
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/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    tools:context="com.example.wilshere.voicerecognitionactivity.VoiceRecognitionActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

    </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/CharacterGrayLight"
    android:orientation="vertical"
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="405dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:background="@drawable/gradientbackground"
            android:layout_height="350dp"
            android:orientation="vertical">
            <ImageView
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_marginTop="20dp"
                android:layout_gravity="center_horizontal"
                android:src="@drawable/round_photo"></ImageView>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="10dp"
                android:text="Your name"
                android:textColor="#fff"
                android:textStyle="bold"
                android:textSize="21sp">
            </TextView>
        </LinearLayout>
        <android.support.v7.widget.CardView
            android:layout_width="350dp"
            android:layout_height="120dp"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="275dp"
            >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:weightSum="3">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:gravity="center"
                    android:layout_height="match_parent">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Рейтинг:"
                        android:textAlignment="center"
                        android:textSize="18sp"></TextView>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="30.5"
                        android:textStyle="bold"
                        android:textSize="20sp"
                        android:paddingTop="10dp"
                        android:textColor="@color/CharacterStartBlue"></TextView>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:gravity="center"
                    android:layout_height="match_parent">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Выполнено задач:"
                        android:textAlignment="center"
                        android:textSize="18sp"></TextView>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="125"
                        android:textStyle="bold"
                        android:textSize="20sp"
                        android:paddingTop="10dp"
                        android:textColor="@color/CharacterStartBlue"></TextView>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:gravity="center"
                    android:layout_height="match_parent">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Возраст:"
                        android:textAlignment="center"
                        android:textSize="18sp"></TextView>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="21"
                        android:textStyle="bold"
                        android:textSize="20sp"
                        android:paddingTop="10dp"
                        android:textColor="@color/CharacterStartBlue"></TextView>
                </LinearLayout>
            </LinearLayout>
        </android.support.v7.widget.CardView>
    </RelativeLayout>

    <ListView
        android:id="@+id/sportsList"
    android:layout_width="match_parent"
    android:layout_height="0dp"
        android:layout_weight="1"
    android:entries="@array/sports_array"
    />

</LinearLayout>



</android.support.v4.widget.DrawerLayout>
ardiien
  • 767
  • 6
  • 26
  • 2
    Possible duplicate of [How to Use Collapsing ToolBar with a ListView instead of a Recycler View](https://stackoverflow.com/questions/32302627/how-to-use-collapsing-toolbar-with-a-listview-instead-of-a-recycler-view) – ardiien Oct 29 '19 at 22:49
  • you can follow this answer: https://stackoverflow.com/a/32201857/5465447 – Roaim Oct 29 '19 at 23:26

1 Answers1

0

You might be looking for RecyclerView + CollapsingToolbarLayout? Check this for more information.

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- Scrollable view here -->

  <com.google.android.material.appbar.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="@dimen/tall_toolbar_height">

    <com.google.android.material.appbar.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleGravity="top"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

      <androidx.appcompat.widget.Toolbar
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          app:layout_collapseMode="pin"/>
    </com.google.android.material.appbar.CollapsingToolbarLayout>
  </com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
ardiien
  • 767
  • 6
  • 26