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

Overview

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.
Comments
  • No resource identifier found for attribute...  error

    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"

    opened by usergoodvery 1
  • Swipe items from SQLite ?

    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.

    help wanted question 
    opened by hendynugraha87 1
  • Using your library

    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!

    opened by Vel-San 0
  • setEnabled functionality

    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.

    opened by Vel-San 0
  • Two new features

    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...

    opened by SoftXperience 0
  • Multiple fixies

    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).

    opened by EmmanuelMess 0
  • currentPosition variable bug fix

    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.

    opened by alierdogan7 0
  • Add option to hide the description

    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

    opened by TaqiyEddine-B 0
  • Title doesn't update in View after using setItems() twice

    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?

    opened by dpather 0
  • capability to add item to swipe selector

    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!

    opened by behi198 1
Owner
Iiro Krankka
Frontend Lead at @reflectly
Iiro Krankka
[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

Andras Kindler 437 Dec 29, 2022
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

Manuel Peinado Gallego 253 Nov 16, 2022
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

Jake Wharton 10.2k Jan 5, 2023
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

Matteo Pellegrino 1 Jan 23, 2019
Silver is a programming language designed to have the look and feel of python combined with the simplicity and efficiency of C, combined with a rich plugin system for extending the capabilities of the language

Silver Programming Language Silver is a programming language designed to resemble Python with some C features, packed with a rich plugin system. Contr

Silver Software 4 Jul 23, 2022
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

Tommy Buonomo 2.8k Jan 5, 2023
A pager for Android with parallax effect

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

Javier Gonzalez 654 Dec 29, 2022
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

Ian Thomas 2.5k Dec 31, 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

Alex Zaitsev 460 Nov 25, 2022
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

Niranjan Kurambhatti 714 Dec 25, 2022
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

Trinea 1.7k Dec 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

Leszek Mzyk 992 Nov 10, 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

Antony Tran 692 Dec 14, 2022
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

Kannan Anbarasan 251 Nov 29, 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. Show some ❤️ ?? Sweet and short libra

Rakshak R.Hegde 180 Nov 18, 2022
Android Parallax-ViewPager

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

ybq 588 Nov 29, 2022
Android LiquidSwipe Library

Android LiquidSwipe Library

Chrisvin Jem 838 Dec 29, 2022
Android Concentric Onboarding library

Android Concentric Onboarding library

Chrisvin Jem 50 Sep 13, 2022
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,

Iman Dolatkia 136 Dec 16, 2022