You could create your own custom button:
This is the layout:
<com.your.package.ui.widget.IncrementButton xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/button_grey" >
<TextView
android:id="@+id/increment_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="+"
android:textColor="@android:color/black"
android:textSize="22sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/increment_label"
android:layout_centerHorizontal="true"
android:text="Max 10"
android:textColor="#FFFFFF"
android:textSize="14sp" />
</com.your.package.ui.widget.IncrementButton>
You need a shape drawable for the background (to show clicks):
You won't have the colors byt just replace them with your colors.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><shape>
<padding android:bottom="10dip" android:left="10dip" android:right="10dip" android:top="10dip" />
<corners android:radius="5dip" />
<stroke android:width="1dip" android:color="@color/black" />
<gradient android:angle="270" android:endColor="@color/button_dark_grey" android:startColor="@color/button_light_grey" />
</shape></item>
<item android:state_focused="true"><shape>
<padding android:bottom="10dip" android:left="10dip" android:right="10dip" android:top="10dip" />
<corners android:radius="5dip" />
<stroke android:width="1dip" android:color="@color/black" />
<gradient android:angle="45" android:endColor="@color/button_dark_grey" android:startColor="@color/button_light_grey" />
</shape></item>
<item><shape>
<padding android:bottom="10dip" android:left="10dip" android:right="10dip" android:top="10dip" />
<corners android:radius="5dip" />
<stroke android:width="1dip" android:color="@color/black" />
<gradient android:angle="270" android:endColor="@color/button_light_grey" android:startColor="@color/button_dark_grey" />
</shape></item>
</selector>
And you then have full control over the button:
package com.your.package.ui.widget;
public class IncrementButton extends RelativeLayout implements OnClickListener {
private OnIncrementClick onIncrementClickListener;
public interface OnIncrementClick {
void onIncrementClick();
}
public IncrementButton(Context context) {
super(context);
init();
}
public IncrementButton(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public IncrementButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(this.onIncrementClickListener != null)
this.onIncrementClickListener.onIncrementClick();
}
public void setOnIncrementClickListener(OnIncrementClick onIncrementClickListener) {
this.onIncrementClickListener = onIncrementClickListener;
}
}
You then can include the button in any of your Layouts, reference it and add a click listener (just like a normal button).
IncrementButton button = (IncrementButton) findViewById(R.id.whatever);
button.setOnIncrementClickListener(yourListener);