Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Feb 21, 2023
2 parents b1455e0 + a0f9e3a commit 339667c
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,41 @@ override fun notifyItemSelected(index: Int) {
}
```

Lastly, you can
Lastly, you can add the item selected listener like the below:

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

### Custom Scrollbar

You can customize attributes of the scrollbar by defining your own style in your `styles.xml` file like the below:

```xml
<style name="PowerSpinnerStyle">
<item name="android:scrollbarAlwaysDrawVerticalTrack">true</item>
<item name="android:scrollbars">vertical</item>
<item name="android:fadeScrollbars">false</item>
<item name="android:scrollbarSize">2dp</item>
<item name="android:scrollbarThumbVertical">@drawable/powerspinner_scrollbar</item>
</style>
```

You can also customize the drawable of the scrollbar by creating `powerspinner_scrollbar.xml` file like the below:

```xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorPrimaryDark" />
<corners android:radius="6dp" />
</shape>
```

Then the library will use the overwritten customized styles.

> **Note**: Please keep in mind you should use the exactly same name for `PowerSpinnerStyle` and `powerspinner_scrollbar.xml` to apply your custom styles.

### PowerSpinnerPreference

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

0 comments on commit 339667c

Please sign in to comment.