https://github.com/adityagohad/HorizontalPicker
A simple, customizable and easy to use picker where centre view is scaled up
https://github.com/adityagohad/HorizontalPicker
android centre customizable horizontalnumberpicker horizontalpicker layoutmanager picker recycler recyclerview scale
Last synced: 2 months ago
JSON representation
A simple, customizable and easy to use picker where centre view is scaled up
- Host: GitHub
- URL: https://github.com/adityagohad/HorizontalPicker
- Owner: adityagohad
- License: apache-2.0
- Created: 2017-06-06T09:48:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-20T11:30:13.000Z (11 months ago)
- Last Synced: 2024-11-09T15:42:26.457Z (8 months ago)
- Topics: android, centre, customizable, horizontalnumberpicker, horizontalpicker, layoutmanager, picker, recycler, recyclerview, scale
- Language: Java
- Size: 979 KB
- Stars: 364
- Watchers: 9
- Forks: 45
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-android-ui - HorizontalPicker - 一个简单的自定义的和容易使用的的picker (选择器(Picker))
README
# HorizontalPicker
A simple, customizable and easy to use picker where centre view is scaled up[](http://www.apache.org/licenses/LICENSE-2.0)
[](https://android-arsenal.com/details/1/5849)
## QuickStart ##
### Include the Gradle dependency ###```java
dependencies {
compile 'com.github.adityagohad:HorizontalPicker:1.0.1'
}
```
Don't forget to add following to build.gradle(Project:{your_project_name>})```
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
```## How to use ##
Your picker will be recyclerView and this lib is just a custom layout manager
to initialize the PickerLayoutManager and set the properties```java
PickerLayoutManager pickerLayoutManager = new PickerLayoutManager(this, PickerLayoutManager.HORIZONTAL, false);
pickerLayoutManager.setChangeAlpha(true);
pickerLayoutManager.setScaleDownBy(0.99f);
pickerLayoutManager.setScaleDownDistance(0.8f);
```
To make it snap to centre use ```SnapHelper``````java
SnapHelper snapHelper = new LinearSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
```
set layout manager of your recyclerVew```java
recyclerView.setLayoutManager(pickerLayoutManager);
```To get selected view use ```onScrollStopListener```
```java
pickerLayoutManager.setOnScrollStopListener(new PickerLayoutManager.onScrollStopListener() {
@Override
public void selectedView(View view) {
//Do your thing
}
});
}
```
## Don't forget this ##
To its core it is a recycler view with custom layout manager so if you forget to add ``` clipToPadding="false" ``` you will never be able to select first and last few elemets(values/views).
So always add paddingLeft and paddingRight like shown below.
```
```