Jump to content

Recommended Posts

Posted (edited)

So I am working on a simple android application and on one of my pages I am going to have a map of my campus. I want to be able to use the pinch to zoom feature to zoom in on the picture and look at it closer.

 

Here is the imageview

<ImageView
        android:id="@+id/imageCampusMap"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/map_description"
        android:gravity="center"
        android:src="@drawable/map" />

My Activity Java file just opens up the xml.

 

public class CampusMap extends Activity {
// Open the layout for the CampusMap Activity
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_campusmap);
	}
	
}

 

 

I thought it would be a simple task to just insert some code to pinch to zoom, but after spending some time googling I came across a large amount of code in order to do this. It was kind of confusing to look at hence why I came here :P

 

Like I found an example here -  http://stackoverflow.com/questions/6758847/pinch-zoom-in-android-for-an-imageview

 

The solution uses something like

 

public class MyImageView extends View {

 

How would my Activity Java file call this view class? That is what was confusing me. Or would this replace my previous activity java file mentioned earlier?

Edited by Corey

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.