Reputation: 774
I have a problem with the CollapsingToolbarLayout
from the already in Android Studio given ScrollingActivity
.
The scrolling down motion works perfectly, but when I want to scroll up, it always shows me that the end of the screen is reached without expanding the Toolbar
again. To expand the Toolbar
, I have to scroll up again, when the end of the screen is reached.
As I'm not really good in explaining the problem I uploaded a Video on YouTube so you can see it by yourself.
VIDEO: https://youtu.be/WrzsY2ooj9o
Also you can see a little bug in there too. The Toolbar collapses by itself sometimes just by making a "bad motion" with the finger, I think you can see it at 0:11.
Thankful for any Help!
<?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"
android:fitsSystemWindows="true"
tools:context="com.appmac.ron.myapplication.ScrollingActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="250dp"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_scrolling" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout>
Upvotes: 3
Views: 1398
Reputation: 2523
With reference to Google issue tracker, Issue is resolved on latest library version 26.1.0.
If any issue persists, please report at Google issue tracker they will re-open to examine.
Upvotes: 0
Reputation: 41
update to 26.0.0-beta2. AppbarLayout should be work as expect. Details:Carry on Scrolling
Ok, I think a third party library can make it work. In fact, I decompiled others app and find this:)
All above was deperated, I find this. There is a easy way to solve this problem. Just set a OnScrollChangeListener listener to your nestedsrollview. The key code is below:
nestScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX,
int oldScrollY) {
if(scrollY == 0) appBarLayout.setExpanded(true);
}
});
The animation will do by method appBarLayout itself.
Upvotes: 3