I want to rotate a Button view by 45 degrees. For that I have written the code which is shown below. Now rather than rotating the Button itself, the text or label on the Button is getting rotated. But I want the Button to get rotated by 45 degrees. How can I accomplish this?
public class MyButton extends Button {
public float degrees;
public float sWidth;
public float sHeight;
public MyButton(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
canvas.save();
canvas.rotate(45.0f);
super.onDraw(canvas);
canvas.restore();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
// TODO Auto-generated method stub
super.onSizeChanged(w, h, oldw, oldh);
sWidth=w;
sHeight=h;
}
}