CarouselView


Source link: https://github.com/sayyam/carouselview

CarouselView

A simple yet flexible library to add carousel view in your android application.

Download

Gradle:

compile 'com.synnapps:carouselview:0.1.4'

Maven:

<dependency>
<groupId>com.synnapps</groupId>
<artifactId>carouselview</artifactId>
<version>0.1.4</version>
<type>pom</type> </dependency>

Usage

Include following code in your layout:

 <com.synnapps.carouselview.CarouselView

android:id="@+id/carouselView"

android:layout_width="match_parent"

android:layout_height="200dp"

app:fillColor="#FFFFFFFF"

app:pageColor="#00000000"

app:radius="6dp"

app:slideInterval="3000"

app:strokeColor="#FF777777"

app:strokeWidth="1dp"/>

Include following code in your activity:

public class SampleCarouselViewActivity extends AppCompatActivity {

CarouselView carouselView;

int[] sampleImages = {
R.drawable.image_1, R.drawable.image_2, R.drawable.image_3, R.drawable.image_4, R.drawable.image_5
}
;

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_sample_carousel_view);

 carouselView = (CarouselView) findViewById(R.id.carouselView);

carouselView.setPageCount(sampleImages.length);

 carouselView.setImageListener(imageListener);

  
}

ImageListener imageListener = new ImageListener() {

@Override

public void setImageForPosition(int position, ImageView imageView) {

 imageView.setImageResource(sampleImages[position]);

}

  
}
;  
}

If you want to add custom view, implement ViewListener.

public class SampleCarouselViewActivity extends AppCompatActivity {

CarouselView customCarouselView;
  int NUMBER_OF_PAGES = 5;

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_sample_carousel_view);

 customCarouselView = (CarouselView) findViewById(R.id.customCarouselView);

customCarouselView.setPageCount(NUMBER_OF_PAGES);

// set ViewListener for custom view 

customCarouselView.setViewListener(viewListener);

  
}

ViewListener viewListener = new ViewListener() {

  @Override

public View setViewForPosition(int position) {

 View customView = getLayoutInflater().inflate(R.layout.view_custom, null);

 //set view attributes here

  return customView;

}

  
}
; 

If you'd like to receive touch events for each image

customCarouselView.setImageClickListener(new ImageClickListener() {

 @Override

 public void onClick(int position) {

  Toast.makeText(SampleCarouselViewActivity.this, "Clicked item: "+ position, Toast.LENGTH_SHORT).show();

 
}

}
);

If using ProGuard add this line to your proguard-rules.pro:

-keep class com.synnapps.carouselview.** {
 *; 
}
 

Supported xml Attributes

Attribute Description Values
app:slideInterval Interval per page in ms. integer
app:indicatorGravity Gravity of the indicator. (Just like layout_gravity) gravity
app:indicatorOrientation Orientation of the indicator. [horizontal, vertical]
app:indicatorVisibility Set visibility of indicator. [visible,invisible,gone]
app:fillColor Color of the filled circle that represents the current page. color
app:pageColor Color of the filled circles that represents pages. color
app:radius Radius of the circles. This is also the spacing between circles. dimension
app:snap Whether or not the selected indicator snaps to the circles. boolean
app:strokeColor Width of the stroke used to draw the circles. color
app:autoPlay Whether or not to auto play. Default: true boolean
app:disableAutoPlayOnUserInteraction Disables autoPlay when user interacts. Default: false boolean
app:indicatorMarginHorizontal Sets horizontal margin for Indicator in Carousel View dimension
app:indicatorMarginVertical Sets vertical margin for Indicator in Carousel View dimension
app:pageTransformInterval Sets speed at which page will slide from one to another in ms. integer
app:pageTransformer Sets page transition animation. [zoom,flow,depth,slide_over]
app:animateOnBoundary Sets whether to animate from last page. Default: true boolean

Note: Add xmlns:app="http://schemas.android.com/apk/res-auto" in your layout's root view.

Developed By

  • Sayyam Mehmood
  • Muhammad Rehan

Special Thanks

This library uses code snippet from Jake Wharton's ViewPagerIndicator to display page indicator.

License

Copyright 2016 Sayyam.  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and  limitations under the License. 

Resources

Simple view to show a kanji from it's SVG representation and animate the drawing.

This is an automatic scrolling view pager slider with circular scrolling which gives you functionality of adding images and adding description of your images along with the pager indicator.

A network abstraction layer over Volley, written in Kotlin and inspired by Moya for Swift.

Animated Pencil Action view for Android.

Markwon is a library for Android that renders markdown as system-native Spannables. It gives ability to display markdown in all TextView widgets (TextView, Button, Switch, CheckBox, etc), Notifications, Toasts, etc. No WebView is required. Library provides reasonable defaults for display style of markdown but also gives all the means to tweak the appearance if desired. All markdown features are supported (including limited support for inlined HTML code, markdown tables and images).

Flubber is an elegant solution for making animations in Android. The library is inspired by the Spring library for iOS. It supports all of the animations, curves and properties that are present in Spring. The library provides an interpolator called Spring which is similar to the iOS CASpringAnimation.

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