A nicer-looking, more intuitive and highly customizable alternative for radio buttons and dropdowns for Android.

Last update: Mar 19, 2022

SwipeSelector

Codacy Badge

Undergoing for some API changes for a 2.0 major version, see example usage in the sample module!

Get it on Google Play

What and why?

Bored of dull looking radio buttons and dropdowns? Me too. I started looking for a more sophisticated way of offering user a choice, and came up with this beautiful dribble.

Unfortunately, there were no ready-made solutions to achieve this, so I spent a good day working on this very thing I call SwipeSelector.

minSDK Version

SwipeSelector supports API levels all the way down to 8 (Android Froyo).

Installation

Gradle:

compile 'com.roughike:swipe-selector:1.0.6'

Maven:

<dependency>
  <groupId>com.roughike</groupId>
  <artifactId>swipe-selector</artifactId>
  <version>1.0.6</version>
  <type>pom</type>
</dependency>

How do I use it?

The usage is really simple.

First add SwipeSelector to your layout file:

<com.roughike.swipeselector.SwipeSelector
    android:value="@+value/swipeSelector"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

Then get a hold of it and give it a set of SwipeItem objects with values, titles and descriptions:

SwipeSelector swipeSelector = (SwipeSelector) findViewById(R.value.swipeSelector);
swipeSelector.setItems(
  // The first argument is the value for that item, and should in most cases be unique for the
  // current SwipeSelector, just as you would assign values to radio buttons.
  // You can use the value later on to check what the selected item was.
  // The value can be any Object, here we're using ints.
  new SwipeItem(0, "Slide one", "Description for slide one."),
  new SwipeItem(1, "Slide two", "Description for slide two."),
  new SwipeItem(2, "Slide three", "Description for slide three.")
);

Whenever you need to know what is the currently showing SwipeItem:

SwipeItem selectedItem = swipeSelector.getSelectedItem();

// The value is the first argument provided when creating the SwipeItem.
int value = (Integer) selectedItem.value;

// for example
if (value == 0) {
  // The user selected slide number one.
}

For an example project using multiple SwipeSelectors, refer to the sample app.

Customization

<com.roughike.swipeselector.SwipeSelector
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:value="@+value/conditionSelector"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:swipe_indicatorSize="10dp"
    app:swipe_indicatorMargin="12dp"
    app:swipe_indicatorInActiveColor="#DDDDDD"
    app:swipe_indicatorActiveColor="#FF00FF"
    app:swipe_leftButtonResource="@drawable/leftButtonResource"
    app:swipe_rightButtonResource="@drawable/rightButtonResource"
    app:swipe_customFontPath="fonts/MySuperDuperFont.ttf"
    app:swipe_titleTextAppearance="@style/MyTitleTextApperance"
    app:swipe_descriptionTextAppearance="@style/MyDescriptionTextApperance"
    app:swipe_descriptionGravity="center" />
swipe_indicatorSize
the size for the circle indicators.
swipe_indicatorMargin
how far the indicators are from each other.
swipe_indicatorInActiveColor
the color for normal unselected indicators.
swipe_indicatorActiveColor
the color for selected indicator.
swipe_leftButtonResource and swipe_rightButtonResource
custom Drawable resources for the left and right buttons. The margins for the content are calculated automatically, so even a bigger custom image won't overlap the content.
swipe_customFontPath
path for your custom font file, such as fonts/MySuperDuperFont.ttf. In that case your font path would look like src/main/assets/fonts/MySuperDuperFont.ttf, but you only need to provide fonts/MySuperDuperFont.ttf, as the asset folder will be auto-filled for you.
swipe_titleTextAppearance and swipe_descriptionTextAppearance
custom TextAppearance for the title and description TextViews for modifying the font sizes and colors and what not.
swipe_descriptionGravity
custom horizontal gravity (in other words alignment) for the description text. Can be either left, center or right. Default should be fine in most cases, but sometimes you might need to modify this.

Apps using SwipeSelector

Send me a pull request with modified README.md to get a shoutout!

Contributions

Feel free to create issues / pull requests.

License

SwipeSelector library for Android
Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).

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.

GitHub

https://github.com/roughike/SwipeSelector
Comments
  • 1. No resource identifier found for attribute... error

    Hi,

    Android 7.1.1. api25 I am unable to set any of the custom attributes, as I get "no resource found.." as per the example below: No resource identifier found for attribute 'swipe_unselectedItemTitle' in package '...'

    My root attribute has:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 xmlns:app="http://schemas.android.com/apk/res-auto"
    

    and all other custom attributes work fine.

    I also tried xmlns:app="http://schemas.android.com/apk/lib/com.roughike.swipeselector"

    Reviewed by usergoodvery at 2017-05-25 10:22
  • 2. Swipe items from SQLite ?

    i already implement your library into my project and it looks marvelous. but sorry for ask, is there any clue how to set of SwipeItem objects using SQLite ? thanks.

    Reviewed by hendynugraha87 at 2016-02-26 15:26
  • 3. Using your library

    Hey, couldn't find another way to tell ya, but thanks for the awesome library:) I just wanted to say that i'm using it now and already included it's name in my app. In case you want to add it to the README, Here is the link to mine

    Cheers mate!

    Reviewed by Vel-San at 2017-12-29 22:24
  • 4. setEnabled functionality

    Hey,

    I'm using your superb library but i'm missing 1 feature, after i press submit/order button i need to lock the selectors, i read the methods you already made and there was no such a thing. I also tried setEnabled(false) and it didn't work.

    Is there a way that i can do that ? Thanks.

    Reviewed by Vel-San at 2017-12-28 10:59
  • 5. Two new features

    Hi, I added two features, I needed for my project:

    • exposed methods to programmatically set the selected item
    • hide the description label if the description is null

    I'm new to this pull request thing here, so let me know if I'm doing anything wrong...

    Reviewed by SoftXperience at 2016-03-10 10:06
  • 6. Multiple fixies

    Deleted unused import, localized strings, ignored AllowBackup and GoogleAppIndexing, deleted unused resources, ignored animations element for API < 11 in swipeselector_layout.xml, added description to move left and right images (this might need some improvement).

    Reviewed by EmmanuelMess at 2016-03-01 22:31
  • 7. currentPosition variable bug fix

    The variable "currentPosition" needs to be updated when a SwipeItem programmmatically selected with selectItemAt() or selectItemWithValue()methods... so that getSelectedItem() method correctly retrieves the current selected item if it was selected programmatically.

    Reviewed by alierdogan7 at 2019-06-10 23:27
  • 8. Add option to hide the description

    When we have nothing to add in the desciption, we simply put noting in the filed "desciption" :

    swipeSelector.setItems(
                    new SwipeItem(0, "1", ""),
                    new SwipeItem(1, "2", ""),
                    new SwipeItem(2, "3", "")
    );
    

    but it's not an optimal solution, the ui is badly affected

    Reviewed by TaqiyEddine-B at 2019-04-27 23:01
  • 9. Title doesn't update in View after using setItems() twice

    Hi!

    I first set the items on create (5 items) and then later set them again using setItems() (to 2 items). They update the actual objects (Adapter and Viewpager just fine with 2 items and correct values) with the view having 2 items but the Title values in the View are not updated and show the values from the initial set (5 items).

    For example if the view has title values of: "1" , "2". "3", "4", "5" on the first setItems() call, on the second setItems() call (with only values "4" and "5"), the title will have the values of "1" and "2", not the expected "4" and "5".

    Please advise on how to update the view to show the updated item values?

    Reviewed by dpather at 2018-05-26 12:31
  • 10. capability to add item to swipe selector

    the capability to add items to swipe selector at run time! for example when some body chooses some thing from a list, it could be added to swipe selector!

    Reviewed by behi198 at 2018-04-15 12:36
  • 11. Cant reset SwipeSelector after calling .setItems method once

    Is there a way to reset the swipeSelector? Either by resetting the swipeSelector and re-setting the SwipeItems or by dynamically changing the SwipeItem data?

    Reviewed by firepadmouse at 2017-04-07 13:12
[Development stopped in 2014. Unfinished and not stable - not recommended to use.] An easy-to-use ViewPager subclass with parallax background effect for Android apps.

Development stopped in 2014 Not developed since 2014. Unfinished and not stable - not recommended to use. ParallaxViewPager An easy-to-use ViewPager s

Dec 31, 2021
Android - A ViewPager page indicator that displays the current page number and (optionally) the page count
Android - A ViewPager page indicator that displays the current page number and (optionally) the page count

NumericPageIndicator A ViewPager page indicator that displays the current page number and (optionally) the page count. It can also display buttons to

Apr 4, 2022
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

May 19, 2022
PagedGrid - Custom android view composed by multiple page grids with custom content and layout
PagedGrid - Custom android view composed by multiple page grids with custom content and layout

PagedGrid A PagedGrid is a ViewPager which pages are GridLayout with equal distributed rows and columns. This project is an Android library, written i

Jan 23, 2019
Three material Dots Indicators for view pagers in Android !
Three material Dots Indicators for view pagers in Android !

Material View Pager Dots Indicator This library makes it possible to represent View Pager Dots Indicator with 3 different awesome styles ! It supports

May 24, 2022
A pager for Android with parallax effect

ParallaxPagerTransformer A pager transformer for Android with parallax effect Installation in your build.gradle file dependencies { // ... com

May 7, 2022
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

May 11, 2022
ViewPagers library for Android

freepager Ready-to-use view pagers for your project. Based on Swipes navigation demo repository Usage: Gradle: dependencies { compile 'pro.alexza

Apr 12, 2022
Android library for fluid tablayout animation as seen on Snapchat.
Android library for fluid tablayout animation as seen on Snapchat.

SnapTabLayout Show some ❤️ and star the repo to support the project This library is the implementation of TabLayout as seen on popular messaging app S

May 18, 2022
Android auto scroll viewpager or viewpager in viewpager
Android auto scroll viewpager or viewpager in viewpager

Android Auto Scroll ViewPager ViewPager which can auto scrolling, cycling, decelerating. ViewPager which can be slided normal in parent ViewPager. Att

May 10, 2022
An android ViewPager extension allowing infinite scrolling

NO LONGER MAINTAINED LoopingViewPager An android ViewPager extension allowing infinite scrolling. You can use it with "standart" PagerAdapter (inflati

Apr 22, 2022
Augment Android's ViewPager with wrap-around functionality.

Infinite View Pager Augment Android's ViewPager with wrap-around functionality. Original StackOverflow question: http://stackoverflow.com/questions/75

May 2, 2022
Android ViewPager template with cool animation.
Android ViewPager template with cool animation.

glazy-viewpager ViewPager template with cool animation. Preview Dependencies compile 'com.android.support:palette-v7:25.2.0' Usage Refer the implement

May 13, 2022
Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. With Kotlin support!
Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. With Kotlin support!

Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. Show some ❤️ ?? Sweet and short libra

Dec 2, 2021
Android Parallax-ViewPager

ParallaxViewPager Demo Usage <com.github.ybq.parallaxviewpager.ParallaxViewPager android:id="@+id/viewpager" android:layout_width="ma

May 12, 2022
Android LiquidSwipe Library
Android LiquidSwipe Library

Android LiquidSwipe Library

May 22, 2022
Android Concentric Onboarding library
Android Concentric Onboarding library

Android Concentric Onboarding library

Dec 22, 2021
Endless full-screen card ViewPager inspired by apple iBook for Android
Endless full-screen card ViewPager inspired by apple iBook for Android

FullScreenCardViewPager for Android Endless full-screen card ViewPager inspired by apple iBook for Android. ✅ We are open to any new feature request,

May 16, 2022
Android App of Pager

Pager Pager allows you to communicate with people without any infrastructure based services like cellular network or Wifi. We make this possible by tr

Dec 1, 2021