Jain
Jain

Reputation: 1

Android Platform: How do i display scrollable, zoomable image

I have a set of 8 images, i want to show them one by one in sequence. Next image will appear once a button is clicked.

I am able to load my image in imageview. 1. I cannot find how to change the image on button click 2. How to make changes in program so that image is scrobbable & zoomable.

enter code here
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_weight="1">
  <ImageView
  android:id="@+id/imageview1"
  android:gravity="center_horizontal"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_weight="1"
  android:src="@drawable/img1"      
  android:adjustViewBounds="true"
  android:keepScreenOn="true" 
  android:scrollbarStyle="outsideOverlay"
  android:scrollbars="horizontal" android:scaleType="fitXY"/>
  <Button      
  android:layout_height="wrap_content"
  android:layout_width="fill_parent"
  android:id="@+id/button1"
  android:text="Next"/>
</LinearLayout>

Upvotes: 0

Views: 1575

Answers (2)

iDroid
iDroid

Reputation: 10533

  1. In the onClickLister of your button call:
    YourImageView.setImageBitmap(YourBitmap);

  2. Check out this link. A great tutorial with basics about multi-touch gestures on Android, it also got an example of how to move around and pinch-zoom an image.

Upvotes: 2

Jack
Jack

Reputation: 9252

For the zoom ImageView, see this post. As far as how to change images when a button is clicked, I would suggest you read how to add a button click listener from here. Google "android button onclick example" and you will find lots of examples. If you are still unsure how to change the Image upon clicking a button, you should check out the Android Developers Guide, it has lots of useful information like handling events, UI, etc...

Also they have some great tutorials here.

Upvotes: 0

Related Questions