How to change CollapsingToolbarLayout typeface and size?

Update Before we dive into the code let’s first decide the textSize for our CollapsingToolbarLayout. Google published a website called material.io, this website also explains the best way on how to deal with Typography. The article mentioned about “Heading” category which also explains the recommended font size to use in sp. Although the article never … Read more

CollapsingToolbarLayout doesn’t recognize scroll fling

I had exactly the same issue with CollapsingToolbarLayout with ImageView inside and NestedScrollView. The fling scroll stops when finger is released. However, I’ve noticed something strange. If you start scrolling with your finger from a view with OnClickListener (e.g. Button), the fling scrolling works perfectly. Thus I fixed it with a weird solution. Set OnClickListener … Read more

Overlap scrolling view with AppBarLayout

In fact, overlaying the scrolling view with the AppBarLayout is an included feature of the Android Design Support Library: you can use the app:behavior_overlapTop attribute on your NestedScrollView (or any View using ScrollingViewBehavior) to set the overlap amount: <android.support.v4.widget.NestedScrollView android:layout_width=”match_parent” android:layout_height=”match_parent” app:layout_behavior=”@string/appbar_scrolling_view_behavior” app:behavior_overlapTop=”64dp”> Note that app:behavior_overlapTop only works on views that have the app:layout_behavior=”@string/appbar_scrolling_view_behavior” as … Read more

How to mimic Google Maps’ bottom-sheet 3 phases behavior?

Note: Read the edits at the bottom OK, I’ve found a way to do it, but I had to change the code of multiple classes, so that the bottom sheet would know of the state of the appBarLayout (expanded or not), and ignore scroll-up in case it’s not expanded: BottomSheetLayout.java Added fields: private AppBarLayout mAppBarLayout; … Read more

Android CollapsingToolbarLayout collapse Listener

I share the full implementation, based on @Frodio Beggins and @Nifhel code: public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener { public enum State { EXPANDED, COLLAPSED, IDLE } private State mCurrentState = State.IDLE; @Override public final void onOffsetChanged(AppBarLayout appBarLayout, int i) { if (i == 0) { if (mCurrentState != State.EXPANDED) { onStateChanged(appBarLayout, State.EXPANDED); } mCurrentState … Read more

Show CollapsingToolbarLayout title only when collapsed

You can add OnOffsetChangedListener to AppBarLayout to determine when CollapsingToolbarLayout is collapsed or expanded and set it’s title. Java final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbarLayout); AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout); appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { boolean isShow = true; int scrollRange = -1; @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (scrollRange == -1) { scrollRange … Read more