百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

HorizontalPicker

> 编程语言
开源

一个适用于 Android 的 HorizontalPicker 视图,支持文本和图标。 :sparkles:

360 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个适用于 Android 的 HorizontalPicker 视图,支持文本和图标。 :sparkles:

Horizontal Picker

A Horizontal picker library for android which supports both text and icons . :pouting_cat:

Gradle Dependency

Add this in your root build.gradle file at the end of repositories:

java
allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Add the dependency :

java
dependencies {
	        compile 'com.github.GoodieBag:HorizontalPicker:v1.0'
	}

Sync the gradle and that's it! :+1:

Features :

  • Supports icons and text or a mixture of both as items of the picker.
  • Tap or scroll horizontally to select the items.
  • Supports drawables, selectors and text highlighting using selectors.
  • Selection change listener to monitor the current selected item.

Usage

XML :

xml

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.

Java :

java
 //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);
Use hpText.setSelectedIndex(index) to select an item programmatically.

Listeners :

A listener exists to monitor the item selection change on slide or on tap.

java
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);

Known Issues :

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.

LICENSE :

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaandroidandroid-libraryandroid-studiojava

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言