Android переработчик вид не прокручивается на младших устройствах с липким заголовком - почему? - PullRequest
0 голосов
/ 27 сентября 2019

У меня есть эта проблема, когда мой просмотрщик не выполняет вложенную прокрутку на API 19 (леденец) ... на последней версии Android все в порядке.используя следующую зависимость: com.android.support:design:26.1.0

и то, что я создал, - это просмотрщик, который должен иметь липкий заголовок.заголовок находится в просмотре карты, а элементы списка находятся под просмотром карты.это выглядит так:

detailscreen.xml:

 <!--wrapping in RelativeLayout until this is resolved: https://stackoverflow.com/questions/57142959/why-latest-version-constraintlayout-doesnt-work-in-nestedscrollview-with-coordi-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

<androidx.cardview.widget.CardView
    android:id="@+id/headerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="4dp">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="@string/ride_hail_meet_at"
            android:textColor="#388bf2"
            app:layout_constraintBottom_toTopOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="parent" />



        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_weatherdata"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:nestedScrollingEnabled="false"
            android:orientation="horizontal"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            app:layout_constraintLeft_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tv_description"
            tools:itemCount="3"
            tools:listitem="@layout/weather_data_row_item"
            tools:visibility="visible" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>

<RelativeLayout
    android:id="@+id/content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/headerView"
    android:layout_alignParentBottom="true"
    android:background="@color/white">


<!--  THIS IS THE RECYCLERVIEW GIVING ME THE PROBLEMS. ITS NOT SCROLLING ON API 19 , WHY ??? -->


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_directions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="16dp"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        tools:itemCount="5"
        tools:listitem="@layout/ride_direction_row" />


</RelativeLayout>

, когда я надуваю эту вещь, она помещается в пользовательский вид CoordinatorLayout.сам этот контейнер можно прокручивать.Что я делаю не так, что он работает на последних версиях Android, но не леденец?я даже попытался использовать appBarLayout и положить туда headerView, но то же самое только на старой версии Android, не работает.Я готов изменить XML полностью, если вы можете предложить лучший подход?

примечание: настройка android: nestedScrollingEnabled = false приведет к тому, что мой recyclerView не будет пересылать сообщения в форме recycler.У меня есть большие изображения в списке, поэтому мне нужна эта функция.

Ответы [ 2 ]

1 голос
/ 27 сентября 2019

так странно, что это единственный способ решить эту проблему:

<?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"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

    <androidx.recyclerview.widget.RecyclerView
      android:id="@+id/recyclerview"
      android:layout_width="match_parent"
      android:layout_height="match_parent"

      app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <com.google.android.material.appbar.AppBarLayout
      android:id="@+id/appbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"    
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

      <com.google.android.material.appbar.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleGravity="bottom"
        app:expandedTitleMarginEnd="@dimen/activity_horizontal_margin"
        app:expandedTitleMarginStart="@dimen/activity_horizontal_margin"
        app:layout_scrollFlags="noScroll"

        app:title="@string/app_name">

        <ImageView
          android:id="@+id/toolbar_image"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:adjustViewBounds="true"
          android:contentDescription="@null"
          android:fitsSystemWindows="true"
          android:scaleType="centerCrop"
          android:src="@drawable/beach_huts" />


      </com.google.android.material.appbar.CollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

так странно, что это работает для всего ... спасибо всем.Ключевым моментом является то, что мне нужно поставить реселлерПЕРВЫЙ выше всего остального.затем определите материал панели приложения.

0 голосов
/ 27 сентября 2019

Вам нужно установить android:layout_height на match_parent или фиксированный размер.

<androidx.recyclerview.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Если вы установите его на wrap_content, он будет расширен до размера его содержимого и, таким образом,не прокручивать.

...