Android Float Picker Widget

Float Picker Widget is an open source Android based widget for picking a number using plus and minus buttons, no typing required. Widget supports whole numbers, decimals, positive values, and negative values. Configuration options include increment size, number of decimal places, minimum value, maximum value, etc. When user holds down button, the widget will continue incrementing the value and accelerate.

Could be used for picking specific scientific values (pH, temperature), AM/FM radio stations, quantity of items to purchase in lots.



1) Setup Layout:

	android:id="@+id/FloatPicker2" />

2) Add listener to activity:

public class DemoActivity extends Activity {

  private float p1_value;

  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {

        FloatPickerWidget fpw1 = (FloatPickerWidget) findViewById(;
        ChangeListener listener1 = new ChangeListener();

  private class ChangeListener implements FloatPickerWidget.ChangeListener {

	public void onValueChange(FloatPickerWidget fpw, float value) {
		// in your app, do something interesting with the value when this fires
		p1_value = value;
		Log.i("Demo App", "Value of the first picker was changed to: " + value);



Configuration options, specified in the XML layout as attributes:

  • button_width – int – width of add and subtract buttons, defaults to 40.
  • button_height – int – height of add and subtract buttons, defaults to LayoutParams.FILL_PARENT.
  • button_text_size – int – size of text labels for buttons, defaults to 20.
  • edittext_width – int – text field width field, defaults to 80.
  • edittext_height – int – text field height, defaults to LayoutParams.FILL_PARENT.
  • edittext_size – int – size of text to use, integer, defaults to 20.
  • add_button_label – String – content of add button, defaults to ‘+’.
  • subtract_button_label – String – content of subtract button, defaults to ‘-‘.
  • minimum_value – float – minimum value allowed, defaults to 0f.
  • maximum_value – float – maximum value allowed, defaults to 100f.
  • default_value – float – default value, defaults to minimum_value.
  • increment_amount – float – amount to add/subtract when button pressed, defaults to 1f.
  • decimal_places – int – number of decimals to display, defaults to 0.
  • starting_repeat_rate – int – initial milliseconds between repeats, defaults to 200, must be above repeat_acceleration.
  • repeat_acceleration – int – milliseconds to decrement the repeat interval on
    each repeat, defaults to 50, do not set below 25.


Apache 2.0

Available on BitBucket:

I look forward to feedback, suggestions, thumbs up, thumbs down, bring it!

Comments are closed.