Reputation: 65
The ZoomInZoomOut extends imageView and allows the user to drag around and zoom in the image using gestures, the DrawView forms a resizeable circle, and this is what I want to show up when the user presses the button
Here's the code implementing what I have...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_display);
Intent intent = getIntent();
String path = getIntent().getStringExtra(ImageDisplayActivity.KEY_PATH);
final Button button = (Button) findViewById(R.id.button1);
try {
java.io.FileInputStream in = this.openFileInput(path);
bitmap = BitmapFactory.decodeStream(in);
bitmap = bitmap.copy(bitmap.getConfig(), true);
touch = (ZoomInZoomOut)findViewById(R.id.IMAGEID);
touch = arrangeImageView(touch);
touch.setImageBitmap(bitmap);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void sendMessage(View view) {
// Do something in response to button click
shape = (DrawView)findViewById(R.id.IMAGEID2);
}
The XML
<com.commonsware.android.test1.ZoomInZoomOut
android:id="@+id/IMAGEID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<com.commonsware.android.test1.DrawView
android:id="@+id/IMAGEID2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AddCircle"
android:id="@+id/button1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:onClick="sendMessage"/>
Upvotes: 0
Views: 34