Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear Gesture from GestureOverlayView in android

Tags:

android

I am using GestureOverlayView to draw any picture I have implemented it successfully,but when i want to draw another picture, I need to clear the previous from the GestureOverlayView in my activity.How can I do it ?

Please look into my code :

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**

            }
        });
    }
like image 561
Arun Avatar asked Dec 11 '22 21:12

Arun


1 Answers

These two lines will clear the created gesture from your activity

gesture.cancelClearAnimation();
gesture.clear(true);
like image 117
Arun Avatar answered Dec 27 '22 14:12

Arun