我正在使用 GestureOverlayView 绘制任何我已经成功实现的图片,但是当我想绘制另一张图片时,我需要从我的活动中的 GestureOverlayView 中清除上一张。我该怎么做?
请查看我的代码:
public class MainActivity extends Activity {
private Button button_save;
private Button button_clear;
private GestureOverlayView gesture;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gesture = (GestureOverlayView) findViewById(R.id.gestures);
button_save = (Button) findViewById(R.id.save_button);
button_clear = (Button) findViewById(R.id.clearbtn);
button_save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
try {
Bitmap gestureImg = gesture.getGesture().toBitmap(100, 100,
8, Color.BLACK);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
gestureImg.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] bArray = bos.toByteArray();
Intent intent = new Intent(MainActivity.this,
Activity2.class);
intent.putExtra("draw", bArray);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(MainActivity.this, "No draw on the string",
3000).show();
}
}
});
button_clear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
**//What to do here to clear my drawn animation**
}
});
}