我想将Button视图旋转45度.为此,我编写了如下所示的代码.现在,不是旋转Button本身,而是按钮上的文本或标签会旋转.但我希望按钮旋转45度.我怎么能做到这一点?
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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14081 次 |
| 最近记录: |