A HorizontalPicker view for android, which supports both text and icon. :sparkles:
A HorizontalPicker view for android, which supports both text and icon. :sparkles:
A Horizontal picker library for android which supports both text and icons . :pouting_cat:
Add this in your root build.gradle file at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}Add the dependency :
dependencies {
compile 'com.github.GoodieBag:HorizontalPicker:v1.0'
}Sync the gradle and that's it! :+1:
P.S : itemWidth and itemHeight are not mandatory. If ignored, it is WRAP_CONTENT by default.
textColorSelector is only applicable when the items are textItems.
//If your picker needs to have text as items :
HorizontalPicker hpText = (HorizontalPicker) findViewById(R.id.picker);
List textItems = new ArrayList<>();
for(int i=1;i imageItems = new ArrayList<>();
imageItems.add(new HorizontalPicker.DrawableItem(R.drawable.example));
imageItems.add(new HorizontalPicker.DrawableItem(R.drawable.example2));
hpImage.setItems(imageItems);hpText.setSelectedIndex(index) to select an item programmatically.A listener exists to monitor the item selection change on slide or on tap.
HorizontalPicker.OnSelectionChangeListener listener = new HorizontalPicker.OnSelectionChangeListener() {
@Override
public void onItemSelect(HorizontalPicker picker, int index) {
HorizontalPicker.PickerItem selected = picker.getSelectedItem();
Toast.makeText(MainActivity.this, selected.hasDrawable() ? "Item at " + (picker.getSelectedIndex() + 1) + " is selected" : selected.getText() + " is selected", Toast.LENGTH_SHORT).show();
}
hpText.setChangeListener(listener);
When the HorizontalPicker is wrapped in an HorizontalScrollView the scroll to select feature of the picker does not work as expected. This will be fixed soon.
…No open issues yet, or sync has not completed.