SimpleViewPager


Source link: https://github.com/fiskurgit/SimpleViewPager

SimpleViewPager

That image ViewPager you have to code for every Android project - use this instead.

Usage

Add to your Android layout xml:

<eu.fiskur.simpleviewpager.SimpleViewPager
  android:id="@+id/simple_view_pager"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  />

set Image scale type, and vertical attributes (see note below):

<eu.fiskur.simpleviewpager.SimpleViewPager
  xmlns:simpleviewpager="http://schemas.android.com/apk/res-auto"
  android:id="@+id/simple_view_pager"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  simpleviewpager:vertical="true"
  simpleviewpager:scaleType="CENTER_CROP"
  />

Then add your images, and setup Picasso ( or Glide, Fresco, or whatever):

SimpleViewPager simpleViewPager = (SimpleViewPager) findViewById(R.id.simple_view_pager);
  String[] demoUrlArray = new String[]{

"http://fiskur.eu/apps/simpleviewpagerdemo/001.jpg",

"http://fiskur.eu/apps/simpleviewpagerdemo/002.jpg",

"http://fiskur.eu/apps/simpleviewpagerdemo/003.jpg",

"http://fiskur.eu/apps/simpleviewpagerdemo/004.jpg",

"http://fiskur.eu/apps/simpleviewpagerdemo/005.jpg", 
}
;  //or use resources shipped with the app. eg: /* int[] resourceIds = new int[]{
 
 R.drawable.a, 
 R.drawable.b, 
 R.drawable.c, 
 R.drawable.d, 
 R.drawable.e 
}
 */  simpleViewPager.setImageUrls(demoUrlArray, new ImageURLLoader() {

  @Override

  public void loadImage(ImageView view, String url) {

Picasso.with(MainActivity.this).load(url).into(view);

  
}

 
}
);
  //optional: int indicatorColor = Color.parseColor("#ffffff");
 int selectedIndicatorColor = Color.parseColor("#fff000");
 simpleViewPager.showIndicator(indicatorColor, selectedIndicatorColor);

If you're using resources that ship with your app make life easy and let Picasso handle the memory management/downsampling and use an array of resources IDs. You can also set the ScaleType for the images (or again; leave that to Picasso in the callback).

Add a ViewPager.OnPageChangeListener if needed: simpleViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { ... } );

Always call simpleViewPager.clearListeners() when the activity/fragment is destroyed to avoid leaks.

Vertical View Pager

You can add simpleviewpager:vertical="true" to your layout xml to get a ViewPager that scrolls vertically, there's quite a few VerticalViewPager solutions around but most are old and unmaintained.

<eu.fiskur.simpleviewpager.SimpleViewPager
  android:id="@+id/simple_view_pager"
  xmlns:simpleviewpager="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  simpleviewpager:vertical="true"/>

There's an additional circlesPaddingBottom in case you're using a BottomSheet floating over the SimpleViewPager and want to offset the pager indicators so they're still onscreen, or aligned vertically central onscreen:

<eu.fiskur.simpleviewpager.SimpleViewPager
  android:id="@+id/simple_view_pager"
  xmlns:simpleviewpager="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  simpleviewpager:vertical="true"
  simpleviewpager:scaleType="CENTER_CROP"
  simpleviewpager:circlesPaddingBottom="60dp"/>

##Dependency

Add jitpack.io to your root build.gradle, eg:

allprojects {

  repositories {

jcenter()

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

  
}
 
}

then add the dependency to your project build.gradle:

dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.github.fiskurgit:SimpleViewPager:1.0.10' 
}

You can find the latest version in the releases tab above: https://github.com/fiskurgit/SimpleViewPager/releases

More options at jitpack.io: https://jitpack.io/#fiskurgit/SimpleViewPager

##Licence

Full licence here: https://github.com/fiskurgit/SyntaxView/blob/master/LICENSE

In short:

The MIT License is a permissive license that is short and to the point. It lets people do anything they want with your code as long as they provide attribution back to you and don’t hold you liable.

Resources

A simple scene manager for Android. CoffeeScene allows to switch the current scene of an Activity, ViewGroup and Fragment (v4 supported). This library can be usefull if you want to switch from a spinner loader to your main content or a placeholder for example.

Android fields validation library based on data binding adapters.

An Android Library for allowing devices manage Wi-Fi Networks.

Android FilterView

Build a simple filter view with customizable controls.

This library helps developer to make calendar without problems.

Styled Map Pager is an awesome first of its type android library for showing a multiple location with different pins along with custom style on a google map with view pager.

It highlights selected location with unique marker pin. It give prominence to certain marker with needs to be highlighted which are selected by you. Also displays selected location in center of screen. Markers are changed with map zoom in and zoom out effects.

Main thing is that this all is binding with pager slider. With sliding of pager map locations are also moves.

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