La vue de défilement imbriquée défile sans à-coups, mais défile vers le haut. Elle est lente. La barre d'outils de synthèse (avec une vue et un cadre d'image) lors du défilement ne rend pas son contenu (reste vide). J'ai essayé tous les drapeaux dans la barre d'outils réductrice.
<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:id="@+id/coordinatorLayout"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:fitsSystemWindows="true">
<Android.support.design.widget.AppBarLayout
Android:id="@+id/appbar"
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:fitsSystemWindows="true"
Android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<Android.support.design.widget.CollapsingToolbarLayout
Android:id="@+id/collapsing_toolbar"
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
Android:id="@+id/backdrop"
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:minHeight="100dp"
Android:fitsSystemWindows="true"
Android:scaleType="centerCrop"
Android:src="@drawable/pic"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.5"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"/>
<include
Android:id="@+id/framelayout"
layout="@layout/header_layout"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
Android:minHeight="100dp"/>
</Android.support.design.widget.CollapsingToolbarLayout>
</Android.support.design.widget.AppBarLayout>
<!-- Your Scrollable View -->
<Android.support.v4.widget.NestedScrollView
Android:id="@+id/nested"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:orientation="vertical"
Android:paddingTop="24dp">
</LinearLayout>
</Android.support.v4.widget.NestedScrollView>
<Android.support.v7.widget.Toolbar
Android:id="@+id/toolbar"
Android:layout_width="match_parent"
Android:layout_height="?attr/actionBarSize"
Android:background="#da1b75"
Android:orientation="horizontal"
Android:textColor="#ffffff"
Android:theme="@style/ThemeOverlay.AppCompat.Light"
app:layout_anchor="@id/appbar"
app:layout_collapseMode="pin"
app:title="">
</Android.support.v7.widget.Toolbar>
Faites en sorte que l'enfant direct de la vue de défilement imbriquée soit cliquable (si vous n'avez pas un seul élément enfant, ajoutez une présentation, insérez-y tous vos éléments d'interface utilisateur et rendez la disposition cliquable).
Android: clickable = "true"
J'étais confronté à un problème similaire et cela a fonctionné pour moi!
Voici le code sur lequel j'ai travaillé -
<?xml version="1.0" encoding="utf-8"?>
<Android.support.design.widget.CoordinatorLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
xmlns:app="http://schemas.Android.com/apk/res-auto"
xmlns:tools="http://schemas.Android.com/tools"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
tools:context="test.testrecycler.MaterialActivity"
>
<Android.support.design.widget.AppBarLayout
Android:layout_width="match_parent"
Android:layout_height="300dp"
Android:theme="@style/AppTheme.AppBarOverlay"
Android:fitsSystemWindows="true"
>
<Android.support.design.widget.CollapsingToolbarLayout
Android:id="@+id/collapsing_toolbar"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleTextAppearance="@style/expandedappbar"
app:collapsedTitleTextAppearance="@style/collapsedappbar"
app:statusBarScrim="@color/colorPrimaryDark"
>
<ImageView
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:src="@drawable/sample"
Android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<Android.support.v7.widget.Toolbar
Android:id="@+id/toolbar"
Android:layout_width="match_parent"
Android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</Android.support.design.widget.CollapsingToolbarLayout>
</Android.support.design.widget.AppBarLayout>
<include layout="@layout/content_material" />
</Android.support.design.widget.CoordinatorLayout>
Et voici le fichier content_material.xml having NestedScrollView.Il a un élément enfant (TextView) qui a été rendu cliquable.
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/content_material"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:paddingBottom="@dimen/activity_vertical_margin"
Android:paddingLeft="@dimen/activity_horizontal_margin"
Android:paddingRight="@dimen/activity_horizontal_margin"
Android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="test.testrecycler.MaterialActivity"
tools:showIn="@layout/activity_material">
<TextView
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:clickable="true"
Android:text="This is an association football club formed in 1983, based in the town of Dover, Kent, England. In the 1989–90 season Dover
Athletic won the Southern League championship, but failed to gain promotion to the Football Conference as the club's ground did not meet
the required standard. Three seasons later the team won the title again and this time gained promotion to the Conference, where they spent
nine seasons before being relegated. The club was transferred to the Isthmian League Premier Division in 2004, but another poor season led
the club to a further relegation. After three seasons in the Isthmian League Division One South, the club won the championship and promotion
back to the Premier Division, and the following season won another championship and promotion to Conference South. In the 2013–14 season,
Dover defeated Ebbsfleet United to return to the Conference Premier after a twelve-year absence. Nicknamed the Whites for their white shirts,
they have played at the Crabble Athletic Ground since the club's formation. Their best performance in the FA Cup was reaching the third
round proper in both the 2010–11 and 2014–15 seasons. (Full article...)
Recently featured: Kalki Koechlin Rogue River (Oregon) Operation Ironside
Archive By email More featured articles...
his time gained promotion to the Conference, where they spent
nine seasons before being relegated. The club was transferred to the Isthmian League Premier Division in 2004, but another poor season led
the club to a further relegation. After three seasons in the Isthmian League Division One South, the club won the championship and promotion
back to the Premier Division, and the following season won another championship and promotion to Conference South. In the 2013–14 season,
Dover defeated Ebbsfleet United to return to the Conference Premier after a twelve-year absence. Nicknamed the Whites for their white shirts,
they have played at the Crabble Athletic Ground since the club's formation. Their best performance in the FA Cup was reaching the third
round proper in both the 2010–11 and 2014–15 seasons. (Full article...)" />
</Android.support.v4.widget.NestedScrollView>
MISE À JOUR: Vous pouvez réduire la taille de l'image en cliquant simplement avec le bouton droit de la souris sur Android STUDIO et sur Convertir l'image en WebP. Cela réduira considérablement la taille de l'image
C'est très simple. J'ai beaucoup lutté et j'ai enfin découvert qu'il s'agissait d'un problème d'image haute résolution que j'avais placée dans src de ImageView. Solution: Réduisez simplement la résolution de l'image en conservant les mêmes dimensions. . (Utilisant probablement Photoshop).
A travaillé pour moi
Je pense que vous oubliez la balise de fermeture pour CoordinatorLayout. Mettez également la barre d’outils sur CollapsingToolbarLayout
<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:id="@+id/coordinatorLayout"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:fitsSystemWindows="true">
<Android.support.design.widget.AppBarLayout
Android:id="@+id/appbar"
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:fitsSystemWindows="true"
Android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<Android.support.design.widget.CollapsingToolbarLayout
Android:id="@+id/collapsing_toolbar"
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
Android:id="@+id/backdrop"
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:minHeight="100dp"
Android:fitsSystemWindows="true"
Android:scaleType="centerCrop"
Android:src="@drawable/pic"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.5"
app:layout_scrollFlags="scroll|exitUntilCollapsed" />
<Android.support.v7.widget.Toolbar
Android:id="@+id/toolbar"
Android:layout_width="match_parent"
Android:layout_height="?attr/actionBarSize"
Android:background="#da1b75"
Android:orientation="horizontal"
Android:textColor="#ffffff"
Android:theme="@style/ThemeOverlay.AppCompat.Light"
app:layout_anchor="@id/appbar"
app:layout_collapseMode="pin"
app:title="Your title">
</Android.support.v7.widget.Toolbar>
<!-- What is this for?
<include
Android:id="@+id/framelayout"
layout="@layout/header_layout"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
Android:minHeight="100dp"/>
-->
</Android.support.design.widget.CollapsingToolbarLayout>
</Android.support.design.widget.AppBarLayout>
<!-- Your Scrollable View -->
<Android.support.v4.widget.NestedScrollView
Android:id="@+id/nested"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:orientation="vertical"
Android:paddingTop="24dp">
</LinearLayout>
</Android.support.v4.widget.NestedScrollView>
</Android.support.design.widget.CoordinatorLayout>
CoordinatorLayout et CollapsingToolbarLayout défilement lisse est un bogue et Google ne l’a toujours pas corrigé. : |
supprimer NestedScrollView. RecyclerView avec app: layout_behavior = "@ string/appbar_scrolling_view_behavior" C'est assez et réparer.
vous pouvez utiliser une bibliothèque tierce: https://github.com/henrytao-me/smooth-app-bar-layout
Je rencontrais des problèmes similaires avec une mise en page contenant coordinator layout
et des fragments contenant RecyclerView
. J'ai ajouté le code suivant dans CollapsingToolbarLayout
pour faciliter le défilement.
app:layout_scrollFlags="scroll|enterAlways"