android - How to set position for image matrix? -


i have gridview images. on long click screen gets dark (with black half transparent image gets visible) , image become visible has same resource of image long clicked grid.

what want able drag image (which have succeeded), image shows @ top corner (as designed layout in xml) , want show clicked (to precised, want center of dragable picture perfumed long click).

my image fill_parent on framelayout , set on matrix scale control position...

this image part of xml:

<imageview     android:id="@+id/imgmainselectedmovie"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:scaletype="matrix"     android:visibility="invisible"     android:src="@drawable/escape" /> 

and ontouch() part:

public boolean ontouch(view v, motionevent ev) {         switch (ev.getaction()) {         case motionevent.action_down:             x = ev.getx();             y = ev.gety();             if (longclicked) return true;             break;         case motionevent.action_move:             if (longclicked) {                 if (!dragstarted) {                     dragstarted = true;                     myimageview.setx(x);                     myimageview.sety(y);                 }             matrix.posttranslate((ev.getx() - x), (ev.gety() - y));             x = ev.getx();             y = ev.gety();             myimageview.setimagematrix(matrix);             return true;             }             break;         case motionevent.action_up:             if (longclicked) {             dark.setvisibility(view.invisible);             myimageview.setvisibility(view.invisible);             longclicked = false;             return true;             }          }         return false;     } 

thist tried solve problem:

if (!dragstarted) {         dragstarted = true; //changed true when onitemlongclick called         myimageview.setx(x);         myimageview.sety(y);             } 

but changes "start point" of image layout entered x , y.

problem solved :) did when onitemlongclick calls took x , y measured action_down case in ontouch, took matrix current location , did posttranslate coordinates action_down minus location of image. solution part onitemlongcliick:

matrix.getvalues(values); matrixx = values[matrix.mtrans_x]; matrixy = values[matrix.mtrans_y]; matrix.posttranslate(x-matrixx, y-matrixy); myimageview.setimagematrix(matrix); 

i'm wondering why didn't put kind of "setplace" method matrix...


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -