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

Drag and Drop functionality in ListView like gmail in android
Android - incrementing global variables
Galaxy Emulator for x86
How to use a webview to show the page of a linkedIn contact?
How to change `solid color` from the code?
android screen orientation mixing up
Show Dialog using PendingIntent
camera intent onActivityResult causes application object and activity to re create
how do I set the listView to the ArrayAdapter, Android
Android Google Maps API V2 - Mark area on the map
Google Analytics V2 (GAV2) Easy Tracker sendView not working
Handler sendMessageDelayed works only the first time
Jump to spinner selection
Change keyboard input text in EditText android
Scroll current tab highlight in ViewPagerIndicator
Inaparent java.lang.NullPointerException

Categories

HOME
uml
phantom-dsl
phpword
assembly
webdriver
yahoo-finance
hessian
sh
can
google-cloud-functions
yandex
aws-cli
3d-reconstruction
hugo
limit
x264
data-visualization
startup
mxgraph
ipmitool
google-form
supervisor
magnetic-cards
azure-iot-hub
fileserver
swagger-2.0
parcelable
object-storage
comparator
dapper-extensions
stackexchange
shared
sqsh
github3.py
least-squares
openerp-7
google-data-api
flask-login
httr
lampp
hammer.js
dtsearch
mongotemplate
singleinstance
page-replacement
video-conferencing
compiler-design
cpu-cache
ampps
mta
x-tag
jclouds
clipboard.js
kango-framework
aurora
wiredep
ons-api
doctype
viola-jones
uncompress
dronekit-android
rdflib
pyobjc
public-html
genymotion-call
wcm
human-computer-interface
build-script
personalization
alternate
gnumeric
drupal-nodes
rolify
ui-select2
abstract-data-type
twisted.web
argouml
device-width
dopostback
xcode3.2
wcf-configuration
iboutlet
cuda-gdb
mapping-by-code
fitbounds
virtualpathprovider
ikimagebrowserview
matlab-load
lr
commerceserver2007
instantiationexception
strtod
wcf-instancing
commercial-application
pnrp

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