Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830
this week in the
Programmer Certification
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Android
Zoom image is not showing
sasa anali
Ranch Hand
Posts: 30
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am trying to click on the link (as below) but nothing happens! It should open big an zoom-able picture
hotel.xml (this is a second file)
<Button android:id="@+id/hotel01small" android:layout_width="fill_parent" android:layout_height="45dp" android:gravity="center" android:text="Picture" android:textSize="10sp" android:textStyle="italic" />
i'm pasting everything to see what's wrong with it
hotel01small.xml
<ImageView android:id="@+id/hotel01small" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="matrix" android:src="@drawable/hotel01" />
H01.java
package com.som.balem; import android.annotation.SuppressLint; import android.app.Activity; import android.graphics.Matrix; import android.graphics.PointF; import android.os.Bundle; import android.util.FloatMath; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; public class H01 extends Activity { ImageView imageDetail1; Matrix matrix = new Matrix(); Matrix savedMatrix = new Matrix(); PointF startPoint = new PointF(); PointF midPoint = new PointF(); float oldDist = 1f; static final int NONE = 0; static final int DRAG = 1; static final int ZOOM = 2; int mode = NONE; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.hotel); setContentView(R.layout.hotel01small); imageDetail1 = (ImageView) findViewById(R.id.hotel01small); imageDetail1.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ImageView view = (ImageView) v; System.out.println("matrix=" + savedMatrix.toString()); switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: savedMatrix.set(matrix); startPoint.set(event.getX(), event.getY()); mode = DRAG; break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); if (oldDist > 10f) { savedMatrix.set(matrix); midPoint(midPoint, event); mode = ZOOM; } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = NONE; break; case MotionEvent.ACTION_MOVE: if (mode == DRAG) { matrix.set(savedMatrix); matrix.postTranslate(event.getX() - startPoint.x, event.getY() - startPoint.y); } else if (mode == ZOOM) { float newDist = spacing(event); if (newDist > 10f) { matrix.set(savedMatrix); float scale = newDist / oldDist; matrix.postScale(scale, scale, midPoint.x, midPoint.y); } } break; } view.setImageMatrix(matrix); return true; } @SuppressLint("FloatMath") private float spacing(MotionEvent event) { float x = event.getX(0) - event.getX(1); float y = event.getY(0) - event.getY(1); return FloatMath.sqrt(x * x + y * y); } private void midPoint(PointF point, MotionEvent event) { float x = event.getX(0) + event.getX(1); float y = event.getY(0) + event.getY(1); point.set(x / 2, y / 2); } }); } }
H01First.java
package com.som.balem; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class H01First extends Activity { Button hotel01small; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.hotel); hotel01small = findViewById(R.id.hotel01small); hotel01small.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // open up the second activity Intent i = new Intent(H01First.this, H01.class); startActivity(i); } }); } }
Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.som.balem" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".PageOneHotel" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > </activity> <activity android:name=".H01" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > </activity> <activity android:name=".H01First" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > </activity> </application> </manifest>
Please help
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
The ImageView shows an image but not working
Zoomed Image is not working
This app is incompatible with your device error in play store Android
Bizarre touch coordinates
Having trouble with OnTouchListener
More...