{"id":15026696,"url":"https://github.com/shawnlin013/numberpicker","last_synced_at":"2025-05-15T16:03:29.093Z","repository":{"id":41203305,"uuid":"60983785","full_name":"ShawnLin013/NumberPicker","owner":"ShawnLin013","description":":slot_machine: The android library that provides a simple and customizable NumberPicker.","archived":false,"fork":false,"pushed_at":"2022-04-25T20:16:02.000Z","size":549,"stargazers_count":1109,"open_issues_count":38,"forks_count":243,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-15T03:28:08.880Z","etag":null,"topics":["android","android-library","android-ui","android-widget","number-picker","numberpicker"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShawnLin013.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"ko_fi":"shawnlin"}},"created_at":"2016-06-12T18:51:06.000Z","updated_at":"2025-05-09T10:06:05.000Z","dependencies_parsed_at":"2022-09-13T10:00:43.916Z","dependency_job_id":null,"html_url":"https://github.com/ShawnLin013/NumberPicker","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShawnLin013%2FNumberPicker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShawnLin013%2FNumberPicker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShawnLin013%2FNumberPicker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShawnLin013%2FNumberPicker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShawnLin013","download_url":"https://codeload.github.com/ShawnLin013/NumberPicker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254374401,"owners_count":22060609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","android-ui","android-widget","number-picker","numberpicker"],"created_at":"2024-09-24T20:04:54.083Z","updated_at":"2025-05-15T16:03:29.062Z","avatar_url":"https://github.com/ShawnLin013.png","language":"Java","funding_links":["https://ko-fi.com/shawnlin","https://ko-fi.com/shawnlin'"],"categories":[],"sub_categories":[],"readme":"# Number Picker\n\nThe android library that provides a simple and customizable NumberPicker.\nIt's based on [android.widget.NumberPicker](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/NumberPicker.java).\n\n[![Platform](http://img.shields.io/badge/platform-android-brightgreen.svg?style=flat)](http://developer.android.com/index.html) [![Language](http://img.shields.io/badge/language-java-orange.svg?style=flat)](http://www.oracle.com/technetwork/java/javase/downloads/index.html) [![](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-NumberPicker-green.svg?style=true)](https://android-arsenal.com/details/1/3718) [![API](https://img.shields.io/badge/API-15%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=15) ![Maven Central](https://img.shields.io/maven-central/v/io.github.ShawnLin013/number-picker) [![CircleCI](https://circleci.com/gh/ShawnLin013/NumberPicker.svg?style=svg)](https://circleci.com/gh/ShawnLin013/NumberPicker)\n[![GitHub stars](https://img.shields.io/github/stars/ShawnLin013/NumberPicker)](https://github.com/ShawnLin013/NumberPicker/stargazers) [![GitHub forks](https://img.shields.io/github/forks/ShawnLin013/NumberPicker)](https://github.com/ShawnLin013/NumberPicker/network)\n\n\u003cimg src=\"https://github.com/ShawnLin013/NumberPicker/blob/master/screenshot/number-picker-theme.png\"\u003e\n\n## Features\n\n- Customizable fonts(color, size, strikethrough, underline, typeface)\n- Customizable dividers(color, distance, length, thickness, type)\n- Horizontal and Vertical mode are both supported\n- Ascending and Descending order are both supported\n- Also supports negative values and multiple lines\n\n## Usage\n\n#### Java\n\n```java\nNumberPicker numberPicker = (NumberPicker) findViewById(R.id.number_picker);\n\n// Set divider color\nnumberPicker.setDividerColor(ContextCompat.getColor(this, R.color.colorPrimary));\nnumberPicker.setDividerColorResource(R.color.colorPrimary);\n\n// Set formatter\nnumberPicker.setFormatter(getString(R.string.number_picker_formatter));\nnumberPicker.setFormatter(R.string.number_picker_formatter);\n\n// Set selected text color\nnumberPicker.setSelectedTextColor(ContextCompat.getColor(this, R.color.colorPrimary));\nnumberPicker.setSelectedTextColorResource(R.color.colorPrimary);\n\n// Set selected text size\nnumberPicker.setSelectedTextSize(getResources().getDimension(R.dimen.selected_text_size));\nnumberPicker.setSelectedTextSize(R.dimen.selected_text_size);\n\n// Set selected typeface\nnumberPicker.setSelectedTypeface(Typeface.create(getString(R.string.roboto_light), Typeface.NORMAL));\nnumberPicker.setSelectedTypeface(getString(R.string.roboto_light), Typeface.NORMAL);\nnumberPicker.setSelectedTypeface(getString(R.string.roboto_light));\nnumberPicker.setSelectedTypeface(R.string.roboto_light, Typeface.NORMAL);\nnumberPicker.setSelectedTypeface(R.string.roboto_light);\n\n// Set text color\nnumberPicker.setTextColor(ContextCompat.getColor(this, R.color.dark_grey));\nnumberPicker.setTextColorResource(R.color.dark_grey);\n\n// Set text size\nnumberPicker.setTextSize(getResources().getDimension(R.dimen.text_size));\nnumberPicker.setTextSize(R.dimen.text_size);\n\n// Set typeface\nnumberPicker.setTypeface(Typeface.create(getString(R.string.roboto_light), Typeface.NORMAL));\nnumberPicker.setTypeface(getString(R.string.roboto_light), Typeface.NORMAL);\nnumberPicker.setTypeface(getString(R.string.roboto_light));\nnumberPicker.setTypeface(R.string.roboto_light, Typeface.NORMAL);\nnumberPicker.setTypeface(R.string.roboto_light);\n\n// Set value\nnumberPicker.setMaxValue(59);\nnumberPicker.setMinValue(0);\nnumberPicker.setValue(3);\n\n// Using string values\n// IMPORTANT! setMinValue to 1 and call setDisplayedValues after setMinValue and setMaxValue\nString[] data = {\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\"};\nnumberPicker.setMinValue(1);\nnumberPicker.setMaxValue(data.length);\nnumberPicker.setDisplayedValues(data);\nnumberPicker.setValue(7);\n\n// Set fading edge enabled\nnumberPicker.setFadingEdgeEnabled(true);\n\n// Set scroller enabled\nnumberPicker.setScrollerEnabled(true);\n\n// Set wrap selector wheel\nnumberPicker.setWrapSelectorWheel(true);\n\n// Set accessibility description enabled\nnumberPicker.setAccessibilityDescriptionEnabled(true);\n        \n// OnClickListener\nnumberPicker.setOnClickListener(new View.OnClickListener() {\n    @Override\n    public void onClick(View view) {\n        Log.d(TAG, \"Click on current value\");\n    }\n});\n\n// OnValueChangeListener\nnumberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {\n    @Override\n    public void onValueChange(NumberPicker picker, int oldVal, int newVal) {\n        Log.d(TAG, String.format(Locale.US, \"oldVal: %d, newVal: %d\", oldVal, newVal));\n    }\n});\n\n// OnScrollListener\nnumberPicker.setOnScrollListener(new NumberPicker.OnScrollListener() {\n    @Override\n    public void onScrollStateChange(NumberPicker picker, int scrollState) {\n        if (scrollState == SCROLL_STATE_IDLE) {\n            Log.d(TAG, String.format(Locale.US, \"newVal: %d\", picker.getValue()));\n        }\n    }\n});\n```\n\n#### XML\n\nadd `xmlns:app=\"http://schemas.android.com/apk/res-auto\"`\n\n```xml\n\u003ccom.shawnlin.numberpicker.NumberPicker\n    android:id=\"@+id/number_picker\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:layout_centerInParent=\"true\"\n    app:np_width=\"64dp\"\n    app:np_height=\"180dp\"\n    app:np_dividerColor=\"@color/colorPrimary\"\n    app:np_formatter=\"@string/number_picker_formatter\"\n    app:np_max=\"59\"\n    app:np_min=\"0\"\n    app:np_selectedTextColor=\"@color/colorPrimary\"\n    app:np_selectedTextSize=\"@dimen/selected_text_size\"\n    app:np_textColor=\"@color/colorPrimary\"\n    app:np_textSize=\"@dimen/text_size\"\n    app:np_typeface=\"@string/roboto_light\"\n    app:np_value=\"3\" /\u003e\n```\n\n### Attributes\n\n|attribute name|attribute description|default|\n|:---:|:---:|:---:|\n|np_width|The width of this widget.|\n|np_height|The height of this widget.|\n|np_accessibilityDescriptionEnabled|Flag whether the accessibility description enabled.|enabled|\n|np_dividerColor|The color of the selection divider.|\n|np_dividerDistance|The distance between the two selection dividers.|\n|np_dividerLength|The length of the selection divider.|\n|np_dividerThickness|The thickness of the selection divider.|\n|np_dividerType|The type of the selection divider.|side_lines|\n|np_fadingEdgeEnabled|Flag whether the fading edge should enabled.|\n|np_fadingEdgeStrength|The strength of fading edge while drawing the selector.|\n|np_formatter|The formatter of the numbers.|\n|np_hideWheelUntilFocused|Flag whether the selector wheel should hidden until the picker has focus.|\n|np_itemSpacing|Amount of space between items.|\n|np_lineSpacingMultiplier|The line spacing multiplier for the multiple lines.|\n|np_max|The max value of this widget.|\n|np_maxFlingVelocityCoefficient|The coefficient to adjust (divide) the max fling velocity.|\n|np_min|The min value of this widget.|\n|np_order|The order of this widget.|ascending|\n|np_orientation|The orientation of this widget.|vertical|\n|np_scrollerEnabled|Flag whether the scroller should enabled.|\n|np_selectedTextAlign|The text align of the selected number.|center|\n|np_selectedTextColor|The text color of the selected number.|\n|np_selectedTextSize|The text size of the selected number.|\n|np_selectedTextStrikeThru|Flag whether the selected text should strikethroughed.|\n|np_selectedTextUnderline|Flag whether the selected text should underlined.|\n|np_selectedTypeface|The typeface of the selected numbers.|\n|np_textAlign|The text align of the numbers.|center|\n|np_textColor|The text color of the numbers.|\n|np_textSize|The text size of the numbers.|\n|np_textStrikeThru|Flag whether the text should strikethroughed.|\n|np_textUnderline|Flag whether the text should underlined.|\n|np_typeface|The typeface of the numbers.|\n|np_value|The current value of this widget.|\n|np_wheelItemCount|The number of items show in the selector wheel.|\n|np_wrapSelectorWheel|Flag whether the selector should wrap around.|\n\n## Gradle\n\nAdd the dependency in your `build.gradle`\n\n```gradle\nbuildscript {\n    repositories {\n        mavenCentral()\n    }\n}\n\ndependencies {\n    implementation 'io.github.ShawnLin013:number-picker:2.4.13'\n}\n```\n\n## Support\n\nThank you to all our backers! 🙏\n\n\u003ca href='https://ko-fi.com/shawnlin' target='_blank'\u003e\u003cimg height='48' style='border:0px;height:48px;' src='https://az743702.vo.msecnd.net/cdn/kofi3.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\n## License\n\nThe source code is licensed under the [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshawnlin013%2Fnumberpicker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshawnlin013%2Fnumberpicker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshawnlin013%2Fnumberpicker/lists"}