PowerSpinner - πŸŒ€ A lightweight dropdown popup spinner, fully customizable with an arrow and animations for Android.

Overview

PowerSpinner


πŸŒ€ A lightweight dropdown popup spinner, fully customizable with an arrow and animations for Android.


License API Build Status Android Weekly Medium Profile Javadoc


Including in your project

Maven Central

Gradle

Add the dependency below to your module's build.gradle file:

dependencies {
    implementation "com.github.skydoves:powerspinner:1.2.1"
}

SNAPSHOT

PowerSpinner
Snapshots of the current development version of PowerSpinner are available, which track the latest versions.

repositories {
   maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}

Usage

Add following XML namespace inside your XML layout file.

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

PowerSpinnerView in XML

You can implement PowerSpinnerView in your XML layout as the below example. You can use PowerSpinnerView same as TextView. For instance, you can set the default text with the hint and textColorHint attributes..

">
<com.skydoves.powerspinner.PowerSpinnerView
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@color/md_blue_200"
  android:gravity="center"
  android:hint="Question 1"
  android:padding="10dp"
  android:textColor="@color/white_93"
  android:textColorHint="@color/white_70"
  android:textSize="14.5sp"
  app:spinner_arrow_gravity="end"
  app:spinner_arrow_padding="8dp"
  app:spinner_divider_color="@color/white_70"
  app:spinner_divider_show="true"
  app:spinner_divider_size="0.4dp"
  app:spinner_item_array="@array/questions"
  app:spinner_item_height="46dp"
  app:spinner_popup_animation="dropdown"
  app:spinner_popup_background="@color/background800"
  app:spinner_popup_elevation="14dp" />

Create PowerSpinner with Kotlin extension

You can also create the PowerSpinnerView programmatically with the Kotlin extension class.

val mySpinnerView = createPowerSpinnerView(this) {
  setSpinnerPopupWidth(300)
  setSpinnerPopupHeight(350)
  setArrowPadding(6)
  setArrowAnimate(true)
  setArrowAnimationDuration(200L)
  setArrowGravity(SpinnerGravity.START)
  setArrowTint(ContextCompat.getColor(this@MainActivity, R.color.md_blue_200))
  setSpinnerPopupAnimation(SpinnerAnimation.BOUNCE)
  setShowDivider(true)
  setDividerColor(Color.WHITE)
  setDividerSize(2)
  setLifecycleOwner(this@MainActivity)
}

Note: It's highly recommended to set the height size of the item with the spinner_item_height attribute or the entire height size of the popup with the spinner_popup_height to implement the correct behaviors of your spinner.

Show and Dismiss

By default, the spinner popup will be displayed when you click the PowerSpinnerView, and it will be dismissed when you select an item. You can also show and dismiss manually with the methods below:

powerSpinnerView.show() // show the spinner popup.
powerSpinnerView.dismiss() // dismiss the spinner popup.

// If the popup is not showing, shows the spinner popup menu.
// If the popup is already showing, dismiss the spinner popup menu.
powerSpinnerView.showOrDismiss()

You can customize the default behaviours of the spinner with the method and property below:

// the spinner popup will not be shown when clicked.
powerSpinnerView.setOnClickListener { }

// the spinner popup will not be dismissed when item selected.
powerSpinnerView.dismissWhenNotifiedItemSelected = false

OnSpinnerItemSelectedListener

You can listen the selection of the spinner items with the setOnSpinnerItemSelectedListener method below:

powerSpinnerView.setOnSpinnerItemSelectedListener<String> { oldIndex, oldItem, newIndex, newText ->
   toast("$text selected!")
}

If you use Java, see the example below:

powerSpinnerView.setOnSpinnerItemSelectedListener(new OnSpinnerItemSelectedListener<String>() {
  @Override public void onItemSelected(int oldIndex, @Nullable String oldItem, int newIndex, String newItem) {
    toast(item + " selected!");
  }
});

Select an Item by an Index

You can select an item manually/initially with the method below:

powerSpinnerView.selectItemByIndex(4)

Note: selectItemByIndex must be invoked after setting items with the setItems method.

Store and Restore a selected Position

You can store and restore the selected position automatically and it will be re-selected automatically when the PowerSpinnerView is inflated with the property below:

powerSpinnerView.preferenceName = "country"

You can also set the property above with the attribute below in your XML layout:

app:spinner_preference_name="country"

You can remove or clear the stored position data with the methods below:

spinnerView.removePersistedData("country")
spinnerView.clearAllPersistedData()

SpinnerAnimation

You can set an animation when you display and dismiss the spinner with the method below:

app:spinner_popup_animation="normal"

This library supports the four animations below:

SpinnerAnimation.NORMAL
SpinnerAnimation.DROPDOWN
SpinnerAnimation.FADE
SpinnerAnimation.BOUNCE
NORMAL DROPDOWN FADE BOUNCE

IconSpinnerAdapter

You can also check out the dafult custom adapter, IconSpinnerAdapter with the setItems and IconSpinnerItem methods below:

spinnerView.apply {
  setSpinnerAdapter(IconSpinnerAdapter(this))
  setItems(
    arrayListOf(
        IconSpinnerItem(text = "Item1", iconRes = R.drawable.unitedstates),
        IconSpinnerItem(text = "Item2", iconRes = R.drawable.southkorea)))
  getSpinnerRecyclerView().layoutManager = GridLayoutManager(context, 2)
  selectItemByIndex(0) // select a default item.
  lifecycleOwner = this@MainActivity
}

Note: You can get the RecyclerView of the spinner with the getSpinnerRecyclerView() method.

If you use Java, see the example below:

List<IconSpinnerItem> iconSpinnerItems = new ArrayList<>();
iconSpinnerItems.add(new IconSpinnerItem("item1", contextDrawable(R.drawable.unitedstates)));

IconSpinnerAdapter iconSpinnerAdapter = new IconSpinnerAdapter(spinnerView);
spinnerView.setSpinnerAdapter(iconSpinnerAdapter);
spinnerView.setItems(iconSpinnerItems);
spinnerView.selectItemByIndex(0);
spinnerView.setLifecycleOwner(this);

Custom Spinner Adapter

You can also implement your own custom adapter and bind to the PowerSpinnerView. Firstly, create a new adapter and viewHolder, which extend each RecyclerView.Adapter and PowerSpinnerInterface below:

class MySpinnerAdapter(
  powerSpinnerView: PowerSpinnerView
) : RecyclerView.Adapter(),
  PowerSpinnerInterface<MySpinnerItem> {

  override var index: Int = powerSpinnerView.selectedIndex
  override val spinnerView: PowerSpinnerView = powerSpinnerView
  override var onSpinnerItemSelectedListener: OnSpinnerItemSelectedListener<MySpinnerItem>? = null

With the custom spinner adapter, you can use your own custom spinner item, which includes information of the spinner item.

Note: You shoud override the spinnerView, onSpinnerItemSelectedListener properties and setItems, notifyItemSelected methods.

Next, you must call spinnerView.notifyItemSelected method when your item is clicked or the spinner item should be changed:

override fun onBindViewHolder(holder: MySpinnerViewHolder, position: Int) {
  holder.itemView.setOnClickListener {
    notifyItemSelected(position)
  }
}

// You must call the `spinnerView.notifyItemSelected` method to let `PowerSpinnerView` know the item is changed.
override fun notifyItemSelected(index: Int) {
  if (index == NO_SELECTED_INDEX) return
  val oldIndex = this.index
  this.index = index
  this.spinnerView.notifyItemSelected(index, this.spinnerItems[index].text)
  this.onSpinnerItemSelectedListener?.onItemSelected(
      oldIndex = oldIndex,
      oldItem = oldIndex.takeIf { it != NO_SELECTED_INDEX }?.let { spinnerItems[oldIndex] },
      newIndex = index,
      newItem = item
    )
}

Lastly, you can

spinnerView.setOnSpinnerItemSelectedListener<MySpinnerItem> { 
  oldIndex, oldItem, newIndex, newItem -> toast(newItem.text) 
}

PowerSpinnerPreference

You can use PowerSpinnerView in your PreferenceScreen XML for building preferences screens. Add the dependency below to your module's build.gradle file:

dependencies {
    implementation "androidx.preference:preference-ktx:1.2.0"
}

You can implement the spinner preference with the PowerSpinnerPreference in your XML file below:

">
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto">

  <androidx.preference.Preference
    android:title="Account preferences"
    app:iconSpaceReserved="false" />

  <com.skydoves.powerspinner.PowerSpinnerPreference
    android:key="question1"
    android:title="Question1"
    app:spinner_arrow_gravity="end"
    app:spinner_arrow_padding="8dp"
    app:spinner_divider_color="@color/white_70"
    app:spinner_divider_show="true"
    app:spinner_divider_size="0.2dp"
    app:spinner_item_array="@array/questions1"
    app:spinner_popup_animation="dropdown"
    app:spinner_popup_background="@color/background900"
    app:spinner_popup_elevation="14dp" />

You don't need to set preferenceName attribute, and OnSpinnerItemSelectedListener should be set on PowerSpinnerPreference. You can reference this sample codes.

{ oldIndex, oldItem, newIndex, newItem -> Toast.makeText(requireContext(), newItem.text, Toast.LENGTH_SHORT).show() }">
val countySpinnerPreference = findPreference<PowerSpinnerPreference>("country")
countySpinnerPreference?.setOnSpinnerItemSelectedListener<IconSpinnerItem> { oldIndex, oldItem, newIndex, newItem ->
  Toast.makeText(requireContext(), newItem.text, Toast.LENGTH_SHORT).show()
}

Avoid Memory Leak

Dialog, PopupWindow and etc.. have memory leak issue if not dismissed before activity or fragment are destroyed. But Lifecycles are now integrated with the Support Library since Architecture Components 1.0 Stable released. So you can solve the memory leak issue simply by setting the lifecycle owner with the method below:

.setLifecycleOwner(lifecycleOwner)

By setting the lifecycle owner, the dismiss() method will be invoked automatically before destroying your activity or fragment.

PowerSpinnerView Attributes

Attributes Type Default Description
spinner_arrow_drawable Drawable arrow arrow drawable.
spinner_arrow_show Boolean true sets the visibility of the arrow.
spinner_arrow_gravity SpinnerGravity end the gravity of the arrow.
spinner_arrow_padding Dimension 2dp padding of the arrow.
spinner_arrow_tint Color None tint color of the arrow.
spinner_arrow_animate Boolean true show arrow rotation animation when showing.
spinner_arrow_animate_duration Integer 250 the duration of the arrow animation.
spinner_divider_show Boolean true show the divider of the popup items.
spinner_divider_size Dimension 0.5dp sets the height of the divider.
spinner_divider_color Color White sets the color of the divider.
spinner_popup_width Dimension spinnerView's width the width of the popup.
spinner_popup_height Dimension WRAP_CONTENT the height of the popup.
spinner_item_height Dimension WRAP_CONTENT a fixed item height of the popup.
spinner_popup_background Color spinnerView's background the background color of the popup.
spinner_popup_animation SpinnerAnimation NORMAL the spinner animation when showing.
spinner_popup_animation_style Style Resource -1 sets the customized animation style.
spinner_popup_elevation Dimension 4dp the elevation size of the popup.
spinner_item_array String Array Resource null sets the items of the popup.
spinner_dismiss_notified_select Boolean true sets dismiss when the popup item is selected.
spinner_debounce_duration Integer 150 A duration of the debounce for showOrDismiss.
spinner_preference_name String null saves and restores automatically the selected position.

Find this library useful? ❀️

Support it by joining stargazers for this repository. ⭐
And follow me for my next creations! 🀩

License

Copyright 2019 skydoves (Jaewoong Eum)

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 L
Comments
  • App Crash on when using the spinner Android 6 and below at library 1.1.8

    App Crash on when using the spinner Android 6 and below at library 1.1.8

    • Library Version [e.g. v1.1.8]
    • Affected Device(s) [Samsung j7 with android 6]

    Describe the Bug:

    Hello, There's a bug that is being reported by crashlytics on Android 5 and 6 and I faced when testing on Android 4.4 that causes the app to crash when using the spinner. it's working fine on Android 10 and Android 8 this the logcat

    opened by ismaelshehada 15
  • setLifecycleOwner

    setLifecycleOwner

    Please complete the following information:

    • Library Version 1.0.3
    • Affected Device(s) [TECNO Camon CX with 7.0, Samsung Galaxy Note 4]

    Describe the Bug: Fatal Exception: java.lang.IllegalArgumentException The observer class has some methods that use newer APIs which are not available in the current OS version. Lifecycles cannot access even other methods so you should make sure that your observer classes only access framework classes that are available in your min API level OR use lifecycle:compiler annotation processor.

    opened by Boscotec 13
  • setOnSpinnerOutsideTouchListener does not fire

    setOnSpinnerOutsideTouchListener does not fire

    Please complete the following information:

    • Library Version [e.g. v1.0.0] : 1.0.5
    • Affected Device(s) : Google Pixel 3a

    Describe the Bug:

    Im using Kotlin with PowerSpinner, setting the onSpinnerOutsideTouchListener using setOnSpinnerOutsideTouchListener { view, motionEvent -> } does not get fired while touching outside spinner when the spinner is open

    Expected Behavior:

    Expect to get event fired when touching outside spinner when the spinner is open, so that I could close the spinner. It would be good if the spinner could be closed when user click the physical back button.

    released 
    opened by davischung 12
  • Request: improve animation when opening/closing

    Request: improve animation when opening/closing

    Is your feature request related to a problem? Seems in the sample animations that it scales the list in animation, so the items look squeezed :

    https://i.imgur.com/R8wPZXW.png

    Describe the solution you'd like: On the native one, it doesn't scale, so it shows nicely (play in super slow motion) :

    https://www.youtube.com/watch?v=on_OrrX7Nw4

    Describe alternatives you've considered: Use native one?

    opened by AndroidDeveloperLB 11
  • Memory leak according to LeakCanary

    Memory leak according to LeakCanary

    Please complete the following information:

    • Library Version: 1.2.0
    • Affected Device(s): Xiaomi Poco F2 Pro

    Describe the Bug: Whenever I add a com.skydoves.powerspinner.PowerSpinnerView to my fragment I get a notification from LeakCanary about a memory leak caused by the PowerSpinnerView. I don't do anything else with it with code, it's just this.

    <com.skydoves.powerspinner.PowerSpinnerView
                android:id="@+id/genreSpinner"
                android:layout_width="80dp"
                android:layout_height="wrap_content"
                android:layout_margin="6dp"
                android:hint="Genre"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"/>
    

    I tried setting the lifecycleowner

    genreSpinner.lifecycleOwner = this <- (Fragment)
    

    With or without it, I still get the memory leak notification.

    When I add the PowerSpinnerView to my main activity layout file (my app uses 1 activity with multiple fragments) I don't have this issue.

    Expected Behavior: No memory leak :)

    Below you can see the notification from LeakCanary:

    ┬───
    β”‚ GC Root: Input or output parameters in native code
    β”‚
    β”œβ”€ android.os.FileObserver$ObserverThread instance
    β”‚    Leaking: NO (PathClassLoader↓ is not leaking)
    β”‚    Thread name: 'FileObserver'
    β”‚    ↓ Thread.contextClassLoader
    β”œβ”€ dalvik.system.PathClassLoader instance
    β”‚    Leaking: NO (InternalLeakCanary↓ is not leaking and A ClassLoader is never
    β”‚    leaking)
    β”‚    ↓ ClassLoader.runtimeInternalObjects
    β”œβ”€ java.lang.Object[] array
    β”‚    Leaking: NO (InternalLeakCanary↓ is not leaking)
    β”‚    ↓ Object[].[378]
    β”œβ”€ leakcanary.internal.InternalLeakCanary class
    β”‚    Leaking: NO (MainActivity↓ is not leaking and a class is never leaking)
    β”‚    ↓ static InternalLeakCanary.resumedActivity
    β”œβ”€ <my_package>.MainActivity instance
    β”‚    Leaking: NO (Activity#mDestroyed is false)
    β”‚    mApplication instance of <my_package>.MainApplication
    β”‚    mBase instance of androidx.appcompat.view.ContextThemeWrapper
    β”‚    ↓ ComponentActivity.mLifecycleRegistry
    β”‚                        ~~~~~~
    β”œβ”€ androidx.lifecycle.LifecycleRegistry instance
    β”‚    Leaking: UNKNOWN
    β”‚    Retaining 1.1 kB in 44 objects
    β”‚    ↓ LifecycleRegistry.mObserverMap
    β”‚                        ~~~~
    β”œβ”€ androidx.arch.core.internal.FastSafeIterableMap instance
    β”‚    Leaking: UNKNOWN
    β”‚    Retaining 932 B in 39 objects
    β”‚    ↓ SafeIterableMap.mEnd
    β”‚                      ~~
    β”œβ”€ androidx.arch.core.internal.SafeIterableMap$Entry instance
    β”‚    Leaking: UNKNOWN
    β”‚    Retaining 56 B in 3 objects
    β”‚    ↓ SafeIterableMap$Entry.mKey
    β”‚                            ~~
    β”œβ”€ com.skydoves.powerspinner.PowerSpinnerView instance
    β”‚    Leaking: UNKNOWN
    β”‚    Retaining 1.9 MB in 9635 objects
    β”‚    View not part of a window view hierarchy
    β”‚    View.mAttachInfo is null (view detached)
    β”‚    View.mID = R.id.null
    β”‚    View.mWindowAttachCount = 1
    β”‚    mContext instance of <my_package>.MainActivity with mDestroyed =
    β”‚    false
    β”‚    ↓ View.mParent
    β”‚           ~~~
    β”œβ”€ androidx.constraintlayout.widget.ConstraintLayout instance
    β”‚    Leaking: UNKNOWN
    β”‚    Retaining 1.5 MB in 5099 objects
    β”‚    View not part of a window view hierarchy
    β”‚    View.mAttachInfo is null (view detached)
    β”‚    View.mID = R.id.null
    β”‚    View.mWindowAttachCount = 1
    β”‚    mContext instance of <my_package>.MainActivity with mDestroyed =
    β”‚    false
    β”‚    ↓ View.mParent
    β”‚           ~~~
    β”œβ”€ androidx.constraintlayout.widget.ConstraintLayout instance
    β”‚    Leaking: UNKNOWN
    β”‚    Retaining 1.4 kB in 22 objects
    β”‚    View not part of a window view hierarchy
    β”‚    View.mAttachInfo is null (view detached)
    β”‚    View.mID = R.id.null
    β”‚    View.mWindowAttachCount = 1
    β”‚    mContext instance of <my_package>.MainActivity with mDestroyed =
    β”‚    false
    β”‚    ↓ View.mParent
    β”‚           ~~~
    β•°β†’ androidx.drawerlayout.widget.DrawerLayout instance
    ​     Leaking: YES (ObjectWatcher was watching this because <my_package>.
    ​     fragments.channelsFragment.ChannelsFragment received
    ​     Fragment#onDestroyView() callback (references to its views should be
    ​     cleared to prevent leaks))
    ​     Retaining 3.2 kB in 91 objects
    ​     key = b686def5-a840-41ef-931a-d2b1a1f03023
    ​     watchDurationMillis = 15996
    ​     retainedDurationMillis = 10996
    ​     View not part of a window view hierarchy
    ​     View.mAttachInfo is null (view detached)
    ​     View.mID = R.id.null
    ​     View.mWindowAttachCount = 1
    ​     mContext instance of <my_package>.MainActivity with mDestroyed =
    ​     false
    
    METADATA
    
    Build.VERSION.SDK_INT: 30
    Build.MANUFACTURER: Xiaomi
    LeakCanary version: 2.7
    App process name: <my_package>
    Stats: LruCache[maxSize=3000,hits=3371,misses=114403,hitRate=2%]
    RandomAccess[bytes=5538838,reads=114403,travel=56894977315,range=28893688,size=3
    6090270]
    Heap dump reason: user request
    Analysis duration: 5416 ms
    
    opened by renezuidhof 10
  • Access to `binding.body`

    Access to `binding.body`

    Is your feature request related to a problem?

    I have the list inside the item of the spinnerRecyclerView. I want to recalculate body height when a list is visible.

    Describe the solution you'd like:

    Additinonal public method:

    fun getSpinnerBody(): RecyclerView = binding.body

    released 
    opened by fturek 10
  • setOnSpinnerOutsideTouchListener does not work (Java)

    setOnSpinnerOutsideTouchListener does not work (Java)

    • Library Version : v 1.0.1

    Description: Java code i wrote to dismiss the spinner when touched outside: spinnerView.setOnSpinnerOutsideTouchListener((view, motionEvent) -> { spinnerView.dismiss(); return null; }); this does not work

    Expected Behaviour: Spinner should dismiss when touched/swiped outside spinner view

    opened by MJ1998 9
  • Height issue still exists.

    Height issue still exists.

    Please complete the following information:

    • Library Version [e.g. v1.1.9]

    Describe the Bug:

    Scenario : If we load a list contains 2 items and later change the list to 4 items the size of the popup not changed.

    Expected Behavior:

    Need to increase the height if the items changes.

    released 
    opened by LokiAndroidBot 8
  • I don't want to use tint feature, means whaterver drawable I will give to arrow, it should show that only.

    I don't want to use tint feature, means whaterver drawable I will give to arrow, it should show that only.

    Please complete the following information:

    • Library Version [e.g. v1.0.0]
    • Affected Device(s) [e.g. Samsung Galaxy s10 with Android 9.0]

    Describe the Bug:

    Add a clear description about the problem.

    Expected Behavior:

    A clear description of what you expected to happen.

    opened by gitam2869 7
  • Arrow color is not changeable on Android 6 device

    Arrow color is not changeable on Android 6 device

    • Library Version 1.0.9
    • Affected Device(s) [e.g. alps 06 with Android 6.0

    Describe the Bug:

    android:textColor="@color/colorDarkGreen" android:background="@color/offWhite" (#eeeeee) app:spinner_arrow_tint="@color/colorDarkGreen" (#00574B)

    Arrow always shows white on older Android version. Even if I change spinner_arrow_tint to #000000

    device-2020-07-18-104222

    Expected Behavior:

    Arrow color should be the same color as the text color, since both are set to the same value. Arrow color is changeable on simulator and on Samsung A10.

    released 
    opened by mikebikemusic 7
  • setOnSpinnerItemSelectedListener with adapter in java

    setOnSpinnerItemSelectedListener with adapter in java

    Hi, i am using this spinner and my code is below

    List iconSpinnerItemss = new ArrayList<>(); iconSpinnerItemss.add(new IconSpinnerItem("View all", ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_map))); iconSpinnerItemss.add(new IconSpinnerItem("Rock", ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_map))); iconSpinnerItemss.add(new IconSpinnerItem("Rocks", ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_map))); iconSpinnerItemss.add(new IconSpinnerItem("Rocks1", ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_map))); iconSpinnerItemss.add(new IconSpinnerItem("Rocks2", ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_map))); iconSpinnerItemss.add(new IconSpinnerItem("Rock3", ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_map))); IconSpinnerAdapter iconSpinnerAdapters = new IconSpinnerAdapter(stonetype_viewdb); stonetype_viewdb.setSpinnerAdapter(iconSpinnerAdapters); stonetype_viewdb.setItems(iconSpinnerItemss); stonetype_viewdb.selectItemByIndex(0); stonetype_viewdb.setIsFocusable(true); stonetype_viewdb.setLifecycleOwner(this);

    How to code for setOnSpinnerItemSelectedListener , while searching i found only kotlin code. can anyone help to code it to get the position of selected item. Thanks

    opened by binu8051 6
  • Dismiss does not work in all cases

    Dismiss does not work in all cases

    Please complete the following information:

    • Library Version v1.2.4
    • Does not have to do with devices

    Describe the Bug:

    In cases where we have a fragment that uses a custom view e.g search bar, and that custom view has a recycler view and in the adapter we use power spinner. If we have opened the spinner and then dismiss the custom view, as result the adapter will be destroyed but the power spinner cannot be dismissed and it's still visible.

    Expected Behavior:

    The power spinner should be dismissed when we destroy a view that contains the spinner.

    opened by GerasimosGots 0
  • Selected IconSpinnerItem's icon not showing if set arrowTint programmatically.

    Selected IconSpinnerItem's icon not showing if set arrowTint programmatically.

    Please complete the following information:

    • Library Version: 1.2.4
    • Affected Device(s): AnyDevice

    Describe the Bug: if set arrowTint color programmtically, Selected IconSpinnerItem's icon not showing. Please see attached screenshot. https://monosnap.com/file/2L7mCqwPNE76JJklQ6wePr3IYOG9B0

    opened by daliborristic883 0
  • More dynamic icons

    More dynamic icons

    Is your feature request related to a problem?

    I am loading some images from a remote server (using Glide), and I want to use them as icons in the spinner. The problem is that it takes time to load the images from the server, so right now I need to load all of the images, and only then add the items to the spinner. It would be much better if I could populate the spinner with text only, and then dynamically add the icons.

    Describe the solution you'd like:

    I'd like to have an option to dynamically set the icons, and as Glide works with ImagesView, a solution I am using for something else which I found quite friendly is to set the icons as ImageViews, and the have the library call ImageView.getDrawable on demand whenever an icon is done loading.

    Describe alternatives you've considered:

    I've considered just building my own spinner with images, as I don't really need a complex spinner, just some basic text and icons.

    opened by Yuvix25 0
  • Items cannot be set dynamically

    Items cannot be set dynamically

    Please complete the following information:

    • Library Version [1.2.4]
    • Affected Device(s) [all]

    Describe the Bug:

    Items cannot be set dynamically

    Expected Behavior:

    Items cannot be set dynamically. If you first set items 1, size=5, select item 5, and then set items 2, size=2, the spinner will crash. Because olditem are obtained from new data sets.

    opened by zqlq4ever 0
  • spinner_arrow_padding is not working in XML

    spinner_arrow_padding is not working in XML

    Please complete the following information:

    • Library Version [v1.2.4]
    • Affected Device(s) [Vivo y33s with Android 12]

    Describe the Bug:

    Hi, overall PowerSpinner works very perfect but here is an issue that the spinner padding is not working, i want to give it custom padding from the end but it's not working, looks like a bug.

    Expected Behavior:

    The Spinner arrow should take custom padding from end to make it little more space from end(move from end).

    Thanks

    opened by ar5-rehman 0
Releases(1.2.4)
  • 1.2.4(Aug 27, 2022)

    What's Changed

    • Fix the spinner arrow doesn't show when the adapter is IconSpinnerAdapter by @skydoves in https://github.com/skydoves/PowerSpinner/pull/129

    Full Changelog: https://github.com/skydoves/PowerSpinner/compare/1.2.3...1.2.4

    Source code(tar.gz)
    Source code(zip)
  • 1.2.3(Jun 18, 2022)

    What's Changed

    • Initialize the arrow tint with no int value and validate it before tinting by @skydoves in https://github.com/skydoves/PowerSpinner/pull/116
    • Bump AGP version to 7.2.0 and compile & target SDK to 32 by @skydoves in https://github.com/skydoves/PowerSpinner/pull/120

    Full Changelog: https://github.com/skydoves/PowerSpinner/compare/1.2.2...1.2.3

    Source code(tar.gz)
    Source code(zip)
  • 1.2.2(May 27, 2022)

    πŸŽ‰ A new version 1.2.2 was released! πŸŽ‰

    What's Changed

    • Update Gradle properties by @skydoves in https://github.com/skydoves/PowerSpinner/pull/108
    • Fixed memory leak issues by @renezuidhof in https://github.com/skydoves/PowerSpinner/pull/111
    • Refactor spotless and add a license format for XML files by @skydoves in https://github.com/skydoves/PowerSpinner/pull/115

    Full Changelog: https://github.com/skydoves/PowerSpinner/compare/1.2.1...1.2.2

    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(May 6, 2022)

    πŸŽ‰ A new version 1.2.1 was released! πŸŽ‰

    What's Changed

    • Add a style to allow clients to customize the scrollbar by @skydoves in https://github.com/skydoves/PowerSpinner/pull/103
    • Added new spinner_popup_max_height attribute and property by @wxw-9527 in https://github.com/skydoves/PowerSpinner/pull/102
    • Implement the setSpinnerPopupMaxHeight method in builder and mark as public the property by @skydoves in https://github.com/skydoves/PowerSpinner/pull/104

    Full Changelog: https://github.com/skydoves/PowerSpinner/compare/1.2.0...1.2.1

    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(May 3, 2022)

    πŸŽ‰ A new version 1.2.0 has been released! πŸŽ‰

    What's Changed

    • Integrate: Binary Validator Plugin by @skydoves in https://github.com/skydoves/PowerSpinner/pull/84
    • Reset index when items are changed by @renezuidhof in https://github.com/skydoves/PowerSpinner/pull/95
    • Make spinner_popup_background supports drawable files by @wxw-9527 in https://github.com/skydoves/PowerSpinner/pull/96
    • Configure maven publication workflows and update dependencies by @skydoves in https://github.com/skydoves/PowerSpinner/pull/97
    • Add modifiers by turning on explicit api mode by @skydoves in https://github.com/skydoves/PowerSpinner/pull/98
    • Refactor resources with resourcePrefix and add public resource ids by @skydoves in https://github.com/skydoves/PowerSpinner/pull/99
    • Added new spinner_item_height attribute and property by @skydoves in https://github.com/skydoves/PowerSpinner/pull/100
    • Fix calculateSpinnerHeight with spanCount of the GridLayoutManager by @skydoves in https://github.com/skydoves/PowerSpinner/pull/101

    New Contributors

    • @renezuidhof made their first contribution in https://github.com/skydoves/PowerSpinner/pull/95
    • @wxw-9527 made their first contribution in https://github.com/skydoves/PowerSpinner/pull/96

    Full Changelog: https://github.com/skydoves/PowerSpinner/compare/1.1.9...1.2.0

    Source code(tar.gz)
    Source code(zip)
  • 1.1.9(Aug 16, 2021)

    πŸŽ‰ Released a new version 1.1.9! πŸŽ‰

    What's New?

    • Fixed: App Crash on when using the spinner Android 6 and below at library 1.1.8 (#75)
    • Added: SpinnerSizeSpec for determining sizes of the arrow. (#72, #77)
    Source code(tar.gz)
    Source code(zip)
  • 1.1.8(Jul 7, 2021)

    πŸŽ‰ Released a new version 1.1.8! πŸŽ‰

    What's New?

    • Added: spinner_popup_focusable attribute.
    • Added: Check lifecycleOwner internally.
    • Fixed: indexOutOfBoundException when set a new item list (#70).
    • Refactored: internal adapters
    Source code(tar.gz)
    Source code(zip)
  • 1.1.7(Dec 9, 2020)

    πŸŽ‰ Released a new version 1.1.7! πŸŽ‰

    What's New?

    • In Java IconSpinnerItem can be created just with 9 parameters (#48)
    • Now the lifecycleOwner will be set automatically while initialization for preventing memory leaks.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.6(Nov 29, 2020)

    πŸŽ‰ Released a new version 1.1.6! πŸŽ‰

    What's New?

    • Removed overScrollMode in the body layout. (0e147d1)
    • Added more options on IconSpinnerItem for customizing related to text color, typeface, icon.
      val text: CharSequence,
      val icon: Drawable? = null,
      @DrawableRes val iconRes: Int? = null,
      @Px val iconPadding: Int? = null,
      val iconGravity: Int = Gravity.START,
      val typeface: Int? = null,
      val gravity: Int? = null,
      val textSize: Float? = null,
      @ColorInt val textColor: Int? = null,
    
    • Changed OnSpinnerItemSelectedListener for notifying the previous selected item and its index.
    setOnSpinnerItemSelectedListener<String> { oldIndex, oldItem, newIndex, newText ->
       toast("$text selected!")
    }
    

    Here is the Java way.

    powerSpinnerView.setOnSpinnerItemSelectedListener(new OnSpinnerItemSelectedListener<String>() {
      @Override public void onItemSelected(int oldIndex, @Nullable String oldItem, int newIndex, String newItem) {
        toast(item + " selected!");
      }
    });
    
    • Changed preference dependency to preference-ktx dependency internally. (3ebc58f)
    • Refactored DefaultSpinnerAdapter and IconSpinnerAdapter internally.
    • Updated Kotlin version to 1.4.20 and Gradle/Wrapper versions.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.5(Oct 13, 2020)

    πŸŽ‰ Released a new version 1.1.5! πŸŽ‰

    What's New?

    • Added getSpinnerViewBody functionalitiy. (#41, #32)
    • Fixed popup height size does not change when using setItems with different item sizes. (#32)
    • Replaced preference dependency to preference-ktx internally.
    Source code(tar.gz)
    Source code(zip)
    powerspinner-1.1.5.aar(87.86 KB)
  • 1.1.4(Oct 8, 2020)

  • 1.1.3(Oct 3, 2020)

    πŸŽ‰ Released a new version 1.1.3! πŸŽ‰

    What's New?

    • Added OnSpinnerDismissListener interface and setOnSpinnerDismissListener function for listening dismissed spinner popup.
    • Added setIsFocusable function. Sets isFocusable of the spinner popup. The spinner popup will got a focus and [onSpinnerDismissListener] will be replaced.
    • Added a Boolean type disableChangeTextWhenNotified field and setDisableChangeTextWhenNotified(Boolean) function. If the value is true, disables changing text automatically when an item selection notified.
    Source code(tar.gz)
    Source code(zip)
    powerspinner-1.1.3.aar(88.43 KB)
  • 1.1.2(Sep 10, 2020)

  • 1.1.1(Sep 5, 2020)

    πŸŽ‰ Released a new version 1.1.1! πŸŽ‰

    What's New?

    • Updated compile SDK version to 30 internally.
    • Updated koltin version to 1.4.0 stable.
    • Intermittent failure to resize the dropdown view after calling spinner.setItems(choices); #32
    • Changed arrowPadding property's default value to 0.
    Source code(tar.gz)
    Source code(zip)
    powerspinner-1.1.1.aar(83.99 KB)
  • 1.1.0(Jul 19, 2020)

  • 1.0.9(May 28, 2020)

  • 1.0.8(May 10, 2020)

  • 1.0.7(Apr 27, 2020)

  • 1.0.6(Apr 16, 2020)

  • 1.0.5(Mar 21, 2020)

  • 1.0.4(Jan 15, 2020)

  • 1.0.3(Jan 7, 2020)

  • 1.0.2(Dec 31, 2019)

    Released version 1.0.2.

    Implemented the below features.

    • We can save and restore automatically using preferenceName attribute. References

    We can save and restore the selected postion automatically. If you select an item, the same position will be selected automatically on the next inflation. Just use the below method or attribute.

    spinnerView.preferenceName = "country"
    
    • We can implement PowerSpinner on PreferenceScreen xml. References
    Source code(tar.gz)
    Source code(zip)
    powerspinner-1.0.2.aar(78.56 KB)
  • 1.0.1(Dec 29, 2019)

  • 1.0.0(Dec 29, 2019)

Owner
Jaewoong Eum
Android Developer Advocate @GetStream πŸ₯‘ β€’ GDE for Android β€’ Open Source Software Engineer ❀️ β€’ Love coffee, music, magic tricks, and writing poems.
Jaewoong Eum
Now deprecated. A small Android library allowing you to have a smooth and customizable horizontal indeterminate ProgressBar

Description Small library allowing you to make a smooth indeterminate progress bar. You can either user your progress bars and set this drawable or us

Antoine Merle 4.4k Dec 30, 2022
A customizable, animated progress bar that features rounded corners. This Android library is designed to look great and be simple to use πŸŽ‰

RoundedProgressBar Easy, Beautiful, Customizeable The RoundedProgressBar library gives you a wide range of customizable options for making progress ba

null 541 Jan 1, 2023
Android loading animations

Android-SpinKit Android loading animations(I wrote a android edition according SpinKit) Demo Apk Preview Gradle Dependency dependencies { implement

ybq 8.4k Jan 5, 2023
Android library for showing progress in a highly customizable pie.

ProgressPieView Android library for showing progress in a highly customizable pie. Choose from the broad spectre of styleable elements: ppvStrokeWidth

Filip PuΔ‘ak 399 Dec 29, 2022
A simple customizable NumberPicker plugin for Android

NumberPicker A simple customizable NumberPicker for Android. Installation via Gradle: compile 'com.github.travijuu:numberpicker:1.0.7' or Maven: <depe

Erkin Γ‡akar 93 Nov 29, 2022
Customizable bouncing dots for smooth loading effect. Mostly used in chat bubbles to indicate the other person is typing.

LoadingDots for Android Customizable bouncing dots view for smooth loading effect. Mostly used in chat bubbles to indicate the other person is typing.

Eyal Biran 162 Dec 2, 2022
Completely customizable progress based loaders drawn using custom CGPaths written in Swift

FillableLoaders Completely customizable progress based loaders drawn using custom CGPaths written in Swift Waves Plain Spike Rounded Demo: Changelog:

Pol Quintana 2.1k Dec 31, 2022
A customizable indeterminate progress bar

DilatingDotsProgressBar Installation compile 'com.github.justzak:dilatingdotsprogressbar:1.0.1' Usage <com.zl.reik.dilatingdotsprogressbar.DilatingDo

Zachary Reik 628 Sep 24, 2022
Completely customizable progress based loaders drawn using custom CGPaths written in Swift

FillableLoaders Completely customizable progress based loaders drawn using custom CGPaths written in Swift Waves Plain Spike Rounded Demo: Changelog:

Pol Quintana 2.1k Dec 31, 2022
A lightweight task progress calendar view library for Android

A lightweight task progress calendar view library for Android

Δ°brahim SΓΌren 128 Oct 21, 2022
A lightweight circular indicator view library for Android

A lightweight circular indicator view library for Android

Δ°brahim SΓΌren 241 Dec 30, 2022
A circular android ProgressBar library which extends View, and the usage same as ProgressBar, It has solid,line and solid_line three styles. Besides, progress value can be freely customized.

CircleProgressBar δΈ­ζ–‡η‰ˆζ–‡ζ‘£ The CircleProgressBar extends View, It has both solid and line two styles. Besides, progress value can be freely customized. I

dinus_developer 1.2k Jan 3, 2023
Android - An action bar item which acts both as a refresh button and as a progress indicator

RefreshActionItem An action bar item that implements this common pattern: Initially it shows a refresh button. If the button is clicked, a background

Manuel Peinado Gallego 655 Nov 10, 2022
ColoringLoading 4.7 0.0 Java This project provide Coloring Loading View for Android. And this project is not using the image file!

ColoringLoading ![Release](https://img.shields.io/github/release/recruit-lifestyle/ColoringLoading.svg?label=maven version) This project provide Color

Recruit Lifestyle Co. Ltd. 379 Jul 25, 2022
Android loading or progress dialog widget library, provide efficient way to implement iOS like loading dialog and progress wheel

ACProgressLite English Version / δΈ­ζ–‡η‰ˆζœ¬ An Android loading widget library. Lite and easy to use, strong customizability. Can be used to implement 'iOS'

Cloudist Technology Co., Ltd. 234 Nov 24, 2022
Android library to realize the various states and transitions in a ProgressBar.

StateProgressBar StateProgressBar is an Android library to realize the various states and transitions in a ProgressBar. Quick Start Get a feel of how

Kofi Gyan 1.5k Jan 9, 2023
IOSProgressBar is a progress-bar lib for android. And the progress-bar looks like iOS system style

IOSProgressBar is a progress-bar lib for android. And the progress-bar looks like iOS system style

heyangyang 6 Aug 25, 2022
Progress Button is a android library for hanling different types state like active, finished, enabled, disabled and reset with a single line of code.

Progress Button is a android library for hanling different types state like active, finished, enabled, disabled and reset with a single line of code.

Sagar Khurana 38 Nov 15, 2022
Present your progress bars in arc mode with information and total control.

ArcProgressStackView Present your progress bars in arc mode with information and total control. You can check the sample app here. Warn This library i

Basil Miller 249 Sep 10, 2022