Created
January 31, 2018 21:12
-
-
Save kjromero/9c4ef4db50ddc6a07e0f79eac41e5ddd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="#FFFFFF" > | |
| <android.gesture.GestureOverlayView | |
| android:id="@+id/gestures" | |
| android:layout_width="fill_parent" | |
| android:layout_height="fill_parent" | |
| android:fadeEnabled="false" | |
| android:fadeOffset="5000000000" | |
| android:gestureColor="#000000" | |
| android:gestureStrokeType="multiple" | |
| android:gestureStrokeWidth="1" | |
| android:uncertainGestureColor="#000000" | |
| android:layout_above="@+id/save_button" /> | |
| <Button | |
| android:id="@id/save_button" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentBottom="true" | |
| android:layout_centerHorizontal="true" | |
| android:layout_marginBottom="20sp" | |
| android:paddingLeft="20sp" | |
| android:paddingRight="20sp" | |
| android:text="Save" | |
| android:textSize="22sp" /> | |
| </RelativeLayout> | |
| ---------------------- Java Acivity 1 | |
| gesture = (GestureOverlayView) findViewById(R.id.gestures); | |
| button_save = (Button) findViewById(R.id.save_button); | |
| 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(Activity1.this, Activity2.class); | |
| intent.putExtra("draw", bArray); | |
| startActivity(intent); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| Toast.makeText(Activity1.this, "No draw on the string", | |
| 3000).show(); | |
| } | |
| } | |
| }); | |
| ---------------------------- Java Activity 2 | |
| ImageView image = (ImageView) findViewById(R.id.image_saved); | |
| ByteArrayInputStream imageStreamClient = new ByteArrayInputStream( | |
| getIntent().getExtras().getByteArray("draw")); | |
| image.setImageBitmap(BitmapFactory.decodeStream(imageStreamClient)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment