appbarlayout-spring-behavior
appbarlayout-spring-behavior copied to clipboard
Image Full Screen Blocked
Hi, thanks for your demo.
I have encountered another issue which happens only when i define a fullscreen image in CollapsingToolbarLayout.
Sometimes when i scroll up to see the content (RecyclerView) below the Image and then scroll down, the image is scrolled automatically until it fit to fullscreen. At that time, i can not re-scroll up anymore to see the the content below the Image.
You can refer to this Video : https://youtu.be/Qw-HLNj5ERU at the 00:25s when i keep trying scroll up (but no success) or at the end of this video.
For the FullScreen Image, layout_collapseMode was none or parallax For AppBarLayout, the behavior was appbar_spring_behavior or appbar_fling_fix_behavior Tested device : Nexus 5x, android 6.0.1
Could you fix this issue please.
Thanks.
Can you show me the xml layout.
Hi, you can try this in your activity_fling_app_bar_layout.xml (just replace The NestedScrollView by RecyclerView and define it in the holding activity)
<?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="@bool/out_fits_system_windows"
tools:context="loopeer.com.appbarlayout_spring_extension.NormalAppBarLayoutActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_fling_fix_behavior"
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">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
android:src="@mipmap/img_test"/>
<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>
<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"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@android:drawable/ic_dialog_email"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_red_dark"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
and in your AppBarFlingFixActivity.java :
package loopeer.com.appbarlayout_spring_extension;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import loopeer.com.appbarlayout_spring_extension.dummy.DummyContent;
public class AppBarFlingFixActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fling_fix_app_bar_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(new MyItemRecyclerViewAdapter(DummyContent.ITEMS));
}
}
Here is the Video : https://youtu.be/crLGtFr_CWY you can see at the 20s, 30s and 43s.
Thanks