android-parallax-recyclerview


Source link: https://github.com/kanytu/android-parallax-recyclerview

android-parallax-recycleview

Integration

Step 1. Add the JitPack repository to your build file

repositories {

  maven {

url "https://jitpack.io"
  
}
 
}
 

Step 2. Add the dependency

dependencies {
  compile 'com.github.kanytu:android-parallax-recyclerview:v1.7' 
}
 

USAGE

(Example project - https://github.com/kanytu/example-parallaxrecycler)

  • Create your object list and pass it to the constructor of ParallaxRecyclerAdapter
List<String> myContent = new ArrayList<String>();
 // or another object list ParallaxRecyclerAdapter<String> adapter = new ParallaxRecyclerAdapter<String>(content) {

 @Override

 public void onBindViewHolderImpl(RecyclerView.ViewHolder viewHolder, ParallaxRecyclerAdapter<String> adapter, int i) {

// If you're using your custom handler (as you should of course) 

// you need to cast viewHolder to it.

((MyCustomViewHolder) viewHolder).textView.setText(myContent.get(i));
 // your bind holder routine.

 
}

  @Override

 public RecyclerView.ViewHolder onCreateViewHolderImpl(ViewGroup viewGroup, final ParallaxRecyclerAdapter<String> adapter, int i) {

// Here is where you inflate your row and pass it to the constructor of your ViewHolder

return new MyCustomViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.myRow, viewGroup, false));

 
}

  @Override

 public int getItemCountImpl(ParallaxRecyclerAdapter<String> adapter) {

// return the content of your array

return myContent.size();

 
}

}
;
  • Now we set the parallax header. You need to pass the RecyclerView too to implement the scroll listeners.
myAdapter.setParallaxHeader(LayoutInflater.from(this).inflate(
  R.layout.myParallaxView, myRecycler, false), myRecyclerView);

There a few other listeners you can implement:

// Event triggered when you click on a item of the adapter. void onClick(View v, int position);

// Event triggered when the parallax is being scrolled. void onParallaxScroll(float percentage, float offset, View parallax);
 

RESULT

COOL EFFECTS YOU CAN DO WITH THIS LIBRARY

  • Transparent toolbar effect
@Override public void onParallaxScroll(float percentage, float offset, View parallax) {

Drawable c = mToolbar.getBackground();

c.setAlpha(Math.round(percentage * 255));

mToolbar.setBackground(c);
 
}

License

Copyright (c) 2014 Pedro Oliveira

Licensed under the Apache License, Version 2.0

Resources

Android calendar view (like card) Simple and easy to modify.

An image with a close button like Google Messenger attachments.

A parallax listview, scrollview and gridview with zoom support.

RefreshableView allows you to refresh ViewGroup, ListView using pull-to-refresh principle.

Variety of tools for Android development: working with thread pool, logging, crashes capturing, etc.

DraggableFlagView allows you to drag the red dot on the certain distance and run "disappear"-callback.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes