Giter Site home page Giter Site logo

awareviewpager's Introduction

AwareViewPager

A ViewPager with a parallax header, transforming toolbar and tabs

Description

This is an example of a ViewPager with a header image, a title box, tabs and a fab. Those views make up the expanded toolbar, which tranlate and transform into a compact toolbar on scrolling of the ViewPager. The ViewPager's fragments watch eachother and update their RecyclerViews scroll positions so that when the ViewPager is scrolled, the adjacent RecyclerView is in the correct position.

Preview

Videos: https://www.youtube.com/watch?v=QqP0todMHnk https://www.youtube.com/watch?v=kCNN7tVDUKc

Alt text

Notes & Issues

The way this works is basically by observing the RecyclerView scroll and a bit of math to translate view in the header accordingly. The important variables the math relys on are in the dimens.xml and used throughout layout files and related classes. This makes the whole system seem quite fragile. For example, going into the examples activity_main.xml and manually changing the header_box height without reflecting that change or directly doing so in dimens.xml will most likely cause some strange scroll behavior.

Initially there was an issue when a RecyclerView didn't have enough items to be scrolled to the top of the screen. If ViewPager frag1 was scrolled to the top and then the user scrolled to frag2, the header would jump down to the correct spot. This was solved by giving the adapter a footer which sized itself acording to the difference between the screen height and the total height of all items in the adapter. It seems to work ok, but occasionally the footer will be largely oversized allowing too much scrolling.

awareviewpager's People

Contributors

hunterstich avatar

Watchers

Rikin Patoliya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.