I would like to add a small counter next to a button to show the remaining quantity for some items, for example, the remaining number of tips remaining unused. Targeted layout would be as shown:
Question:
I have researched the web and found that some say to use different pictures for each quantity. Yet how could it be solved if the quantity can be up to 100? Really necessary to draw such out?
I am thinking of to stick 2 buttons together in a RelativeLayout
such that when the user presses the bottom button, the top button will count up and down and setText
itself, but are there some better solutions or imports?
Edit:
Thanks Rupesh for your codes and advice! I have implemented as follows. Yet do you know how to move the red circle textview further to the right? and the 20 cannot be properly shown in the red circle too...
Code:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" >
<Button
android:id="@+id/button_tip"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="1dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="5dp"
android:background="@drawable/orange_btn"
android:onClick="button_tip_click"
android:text="Hello" />
<TextView
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|right"
android:background="@drawable/red_circle_btn"
android:gravity="center"
android:text="20"
android:textColor="@color/white"
android:textSize="8sp"
android:textStyle="bold" />
</FrameLayout>