I want to rotate the text on the button, but I could not do it all day.
I tried Custom Vertical Button but it is not centering the text in the button. I tried all gravity options in java and xml code.
Here is my VerticalButton code:
public class VerticalButton extends Button{
public VerticalButton(Context context, AttributeSet attrs){
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}
@Override
protected void onDraw(Canvas canvas){
TextPaint textPaint = getPaint();
textPaint.setColor(getCurrentTextColor());
textPaint.drawableState = getDrawableState();
canvas.save();
canvas.translate(0, getHeight());
canvas.rotate(-90);
canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop());
getLayout().draw(canvas);
canvas.restore();
}
}
I tried rotate Button with android:rotation="-90"
That didn't work the way I wanted. Because it is not editing the background size.
I tried Relative Layout with Button and TextView but I couldn't bring the TextView over the Button
Thanks in advance.