我正在尝试在我创建的SurfaceView对象的onDraw方法中创建一个简单路径,并且每当我向路径添加arcTo命令时,布局编辑器都会给我“UnsupportedOperationException:null”。
我该如何解决这个问题?
谢谢,
赖安
public class myView extends SurfaceView
{
private Path myPath;
public myView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
//set bounds
final int top = 0 +this.getPaddingTop();
final int bottom = this.getMeasuredHeight() - this.getPaddingBottom();
final int left = 0 + this.getPaddingLeft();
final int right = this.getMeasuredWidth() - this.getPaddingRight();
int someHeight;
int someWidth;
innerLeft = new RectF(left + someWidth, bottom - otherHeight,
left + someHeight + 10 * 2, bottom);
myPath.moveTo(left, bottom);
myPath.lineTo(left, top + 10);
myPath.arcTo(innerLeft, 180, 90);
myPath.close();
}
}