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

Related tags

UI/UX SwipeSelector
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
Iiro Krankka
Highly customizable SlidingLayer as you have seen in Wunderlist

6Wunderkinder SlidingLayer for Android This repository hosts a library that provides an easy way to include an autonomous layer/view that slides from

Microsoft Archive 942 Nov 28, 2022
Highly customizable SlidingLayer as you have seen in Wunderlist

6Wunderkinder SlidingLayer for Android This repository hosts a library that provides an easy way to include an autonomous layer/view that slides from

Microsoft Archive 942 Nov 28, 2022
SwipeBack for Android Activities to do pretty the same as the android "back-button" will do, but in a really intuitive way by using a swipe gesture

SwipeBack SwipeBack is for Android Activities to do pretty the same as the android "back-button" will do, but in a really intuitive way by using a swi

Hannes Dorfmann 697 Dec 14, 2022
Another-read-more-lib - Another read more library for android

another-read-more-lib ?? Another read more library. Add it in your root build.gr

Geovani Amaral 9 Nov 2, 2022
Parallax everywhere is a library with alternative android widgets with parallax effects.

Parallax Everywhere# Parallax everywhere (PEW) is a library with alternative android views using parallax effects. Demo You can try the demo app on go

fmSirvent 712 Nov 14, 2022
Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle!

LabeledSeekSlider Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle! Minimum target

Edgar Žigis 78 Sep 27, 2022
Highly customized vertical Seekbar with segments

SegmentedVerticalSeekBar It is an Android Vertical Seekbar with segments develop

smartSense Solutions 15 Dec 31, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Dec 30, 2022
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

Frederik Schweiger 1.5k Dec 30, 2022
Awesome RunnerBe design system and more!

Honeycomb Awesome RunnerBe design system and more! Core Preview 아직 모든 요소가 구현되지 않았으며 단순히 미리보기 입니다 class MainActivity : AppCompatActivity() { overri

RunnerBe 2 Apr 21, 2022
The CustomCalendarView provides an easy and customizable calendar to create a Calendar. It dispaly the days of a month in a grid layout and allows to navigate between months

Custom-Calendar-View To use the CustomCalendarView in your application, you first need to add the library to your application. You can do this by eith

Nilanchala Panigrahy 113 Nov 29, 2022
Customizable Item Setting View Android

ItemSettingView Simple ItemSettingView and Custom Installation Add it in your root build.gradle at the end of repositories: allprojects { reposito

Andhika Yuana 15 Aug 19, 2022
Fully customizable implementation of "Snowfall View" on Android.

Android-Snowfall Fully customizable implementation of "Snowfall View" on Android. That's how we use it in our app Hotellook Compatibility This library

Jetradar Mobile 1.2k Dec 21, 2022
Celebrate more with this lightweight confetti particle system 🎊

Konfetti ?? ?? Celebrate more with this lightweight confetti particle system. Create realistic confetti by implementing this easy to use library. Demo

Dion Segijn 2.7k Jan 2, 2023
:balloon: A lightweight popup like tooltips, fully customizable with an arrow and animations.

Balloon ?? A lightweight popup like tooltips, fully customizable with arrow and animations. Including in your project Gradle Add below codes to your r

Jaewoong Eum 2.8k Jan 5, 2023
A simple and customizable two or three states Switch View

RMSwitch A simple View that works like a switch, but with more customizations. With the option to choose between two or three states. (from v1.1.0) **

Riccardo Moro 656 Dec 2, 2022
A customizable debug screen to view and edit flags that can be used for development in Jetpack Compose applications

Tweaks A customizable debug screen to view and edit flags that can be used for development in Jetpack Compose applications To include the library add

Guillermo Merino Jiménez 4 Jan 14, 2022
A new canvas drawing library for Android. Aims to be the Fabric.js for Android. Supports text, images, and hand/stylus drawing input. The library has a website and API docs, check it out

FabricView - A new canvas drawing library for Android. The library was born as part of a project in SD Hacks (www.sdhacks.io) on October 3rd. It is cu

Antwan Gaggi 1k Dec 13, 2022
MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.

About MarkdownView (Markdown For Android) is an Android library that helps you display Markdown text or files (local/remote) as formatted HTML, and st

Feras Alnatsheh 1k Dec 20, 2022