android


how to get imageview height and width after pinch zoom?


In my application I want to get image view height and width after zoom the image.This is the code for zoom the image view. This is onCreate method..
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnGet=(Button) findViewById(R.id.get);
relImage=(RelativeLayout) findViewById(R.id.image);
imgMarker = (ImageView) findViewById(R.id.imagemarker);
btnGet.setOnClickListener(this);
dragImage=BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
imgMarker.setImageBitmap(dragImage);
imgMarker.setOnTouchListener(this);
}
And this is ontouch method..
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
ImageView view = (ImageView) v;
view.setScaleType(ImageView.ScaleType.MATRIX);
float scale;
// Handle touch events here...
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: // first finger down only
savedMatrix.set(matrix);
start.set(event.getX(), event.getY());
Log.d(TAG, "mode=DRAG"); // write to LogCat
mode1 = DRAG1;
break;
case MotionEvent.ACTION_UP: // first finger lifted
x_cordinate=event.getX();
y_cordinate=event.getY();
Log.e("height====",""+dragImage.getHeight());
Log.e("width=====",""+dragImage.getWidth());
Log.e("x_cordinate==",""+x_cordinate);
Log.e("y_cordinate==",""+y_cordinate);
break;
case MotionEvent.ACTION_POINTER_UP: // second finger lifted
mode1 = NONE1;
Log.d(TAG, "mode1=NONE1");
break;
case MotionEvent.ACTION_MOVE:
if (mode1 == DRAG1){
matrix.set(savedMatrix);
matrix.postTranslate(event.getX() - start.x, event.getY() - start.y); // create the transformation in the matrix of points
}
else if (mode1 == ZOOM1){
// pinch zooming
float newDist = spacing(event);
Log.d(TAG, "newDist=" + newDist);
if (newDist > 5f){
matrix.set(savedMatrix);
scale = newDist / oldDist; // setting the scaling of the
matrix.postScale(scale, scale, mid.x, mid.y);
}
}
break;
case MotionEvent.ACTION_POINTER_DOWN:
oldDist = spacing(event);
Log.d(TAG, "oldDist=" + oldDist);
if (oldDist > 10f) {
savedMatrix.set(matrix);
midPoint(mid, event);
mode1 = ZOOM1;
Log.d(TAG, "mode=ZOOM" );
}
break;
}
view.setImageMatrix(matrix); // display the transformation on screen
return true; // indicate event was handled
}
And this is xml file..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="get"
android:id="#+id/get"/>
<RelativeLayout
android:id="#+id/image"
android:layout_marginTop="10dp"
android:layout_below="#+id/get"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<ImageView
android:scaleType="matrix"
android:visibility="gone"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="#+id/imagemarker"/>
</RelativeLayout>
</RelativeLayout>
In this switch case MotionEvent.ACTION_UP, I am getting the image view height and width. But these values are same after zoom the image also.So please suggest me how to do? Thanks In advance to all..

Related Links

Getting errors on Generate Signed APK in Android Studio 2
Integrate the library project in Andorid Studio [duplicate]
Recycler view Inside NestedScrollView with CoordinatorLayout
Android Watch not receive message
Using IN in Content Provider
Can we get the cell tower location of unregistered network android?
how to disable a row of listview in android?
OnclickListener in a Dialog Android
buffer and play videos faster in VideoView
multiple spinner android depend on each other
Android get fit bit user profile
ASP.Net Identity Web API 2 Facebook authentication
Gradle: No resource type specified (at 'text' with value '#{user.name}'). Databinding not working
cordova-plugin-device-motion Exception in start() method
Quickblox SDK 2.5.2 - Incoming call is not receive issue in Android
How to get Google play services back to work with new Genymotion 2.7.2?

Categories

HOME
service-worker
twitter-bootstrap-3
turing-machines
amp-html
apache-spark-mllib
sitecore
newrelic
aws-cli
vxml
square
android-json
fosrestbundle
pega
redis-sentinel
emoji
filechannel
renjin
docx
jersey-1.0
sse
r-mice
flask-sqlalchemy
ckfinder
windows-server-2003
beautifier
licensing
ms-access-2003
soot
uitapgesturerecognizer
sqsh
jmockit
laravel-eloquent
github3.py
zoomify
connection-pool
protein-database
bc
apns-php
cin
urlsession
spring-mvc-test
vmware-fusion
branching-and-merging
subclipse
clang++
apache-directory
jboss-4.2.x
fclose
dbcontext
singleinstance
type-theory
usart
atlas
wso2developerstudio
cifilter
firebase-security
refinerycms
clipboard.js
freepbx
riot
tracker-enabled-dbcontext
redis-cluster
libav
qbxml
ascii-art
relativelayout
r-package
visual-sourcesafe-2005
sql-server-data-tools
cwrsync
snoop
iiop
entry-point
paw
jama
kissfft
tinyxml
bin
dtmf
hidapi
qtconcurrent
faye
entity-attribute-value
creole
xui
django-paypal
undefined-index
lxr
build-environment
complex-event-processing
blind

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App