4

In iOS, there is the Stepper control that has a plus and minus button to change a value.

I could not find a similar control in both the Android developer and the material design documentation.

What is the "official Android way" of doing an "increase/decrease" button?

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
PastAndSalmon
  • 175
  • 2
  • 11

2 Answers2

3

Stepper(increase/decrease value) control for Android?

There is no Built in control available like Stepper in Android

But your can try this way

<LinearLayout
    android:layout_width="wrap_content"
    android:background="#ffffff"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageButton
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@drawable/ic_add_black" />

    <ImageButton
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@drawable/ic_remove" />

</LinearLayout>

android:src="@drawable/ic_add_black"

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>

android:src="@drawable/ic_remove"

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M19,13H5v-2h14v2z"/>
</vector>

OUTPUT

enter image description here

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
  • Thank you for the implementation. I'm more interested in if Material design has a recommendation of how to do it or if the SDK has a control for this. – PastAndSalmon Sep 06 '18 at 12:29
  • 1
    @PastAndSalmon There is no Built in control available like Stepper in Android – AskNilesh Sep 06 '18 at 12:36
1

As @Nilesh Rathod said, there's no built in solution. You can create your own or make use of some third-party library available. For example this looks good:

https://github.com/ashik94vc/ElegantNumberButton

sebasira
  • 1,739
  • 1
  • 22
  • 41