question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alt use of AppBarLayout - Possible to mimic play sotre behavior on "scroll up"/"scroll to top"

See original GitHub issue

I was trying to use AppBarLayout like this:

          <AppBarLayoutAndroid
            layoutWidthAndroid="matchParent"
            layoutHeightAndroid="wrapContent"
          >
            {/* Elements directily in <AppBarLayoutAndroid> can have an     */}
            {/* additional scrollFlagsAndroid prop. This must be an array   */}
            {/* of strings, specifying the scroll flags of this element.    */}
            {/* see https://goo.gl/RiAyDX for reference.                    */}
            <View scrollFlagsAndroid={['scroll']}>
              <Text style={{ fontSize: 18 }}>Hi, I will be collapsed when scrolling down, and show again when scrolled to top.</Text>
            </View>
            <View scrollFlagsAndroid={['scroll', 'enterAlways']}>
              <Text style={{ fontSize: 18 }}>Hi, I will be collapsed when scrolling down, and show again when scrolling up.</Text>
            </View>
            <View scrollFlagsAndroid={[]}>
              <Text style={{ fontSize: 18 }}>Hi, I will not be collapsed.</Text>
            </View>
          </AppBarLayoutAndroid>

From this discontinued repo - https://github.com/zetavg/react-native-android-design-support#coordinatorlayout

I was hoping to mimic the playstore behavior:

HD screen recording: https://gfycat.com/ShockingQuickGalapagosdove

GIF screen recording:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
cesardeazevedocommented, Mar 21, 2018

Hi, you need to enable the following scrollFlags:

SCROLL_FLAG_SCROLL | SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED | SCROLL_FLAG_ENTER_ALWAYS

Here’s a practical example.

<CollapsingToolbarLayout
  title='Collapsing Toolbar'
  scrollFlags={
      AppBarLayout.SCROLL_FLAG_SCROLL
    | AppBarLayout.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED
    | AppBarLayout.SCROLL_FLAG_ENTER_ALWAYS
    }>
</CollapsingToolbarLayout>

Let me know if you got it.

0reactions
cesardeazevedocommented, May 16, 2018

Thanks for sharing it.

I just saw they move to a JS solution, sadly 😞

This is one those things that would play nicely inside a native navigation solution, such as airbnb native-navigation, but that’s not something easy to do.

But anyway, i still have my doubts about how that could works, but i will give a try, thanks for sharing it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AppBarLayout scroll behavior with layout_scrollFlags - Medium
Basically, app:layout_scrollFlags attribute must have one of the 5 values (or a few of them combined). In my examples I use a Toolbar...
Read more >
AppBarLayout with scrolling behavior alternative/ sticky view ...
I wanted to use RecyclerView with multiple view types and treat the views in group a and b above as different ViewHolders and...
Read more >
Handling Scrolls with CoordinatorLayout - CodePath Cliffnotes
Any scroll events to the RecyclerView should trigger changes to the AppBarLayout layout or any views contained within it. Scroll events in the...
Read more >
AppBarLayout | Android Developers
AppBarLayout is a vertical LinearLayout which implements many of the features of material designs app bar concept, namely scrolling gestures ...
Read more >
App bars: top - Material Design
The top app bar displays information and actions relating to the current view. ... Applying scrolling behavior to the prominent top app bar....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found