Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set position for image matrix?
    primarykey
    data
    text
    <p>I have a <code>GridView</code> with images. On long click the screen gets dark (with black half transparent image that gets visible) and another image become visible that has the same resource of the image long clicked from the grid.</p> <p>What i want is to be able to drag that image (which i have succeeded), but the image shows at the top corner (as i designed the layout in the XML) and I want it to show up where I clicked (To be precised, i want the center of the dragable picture to be where I perfumed the long click).</p> <p>My image is <code>fill_parent</code> on <code>FrameLayout</code> and is set on matrix scale to control position...</p> <p>this is the image part of the XML:</p> <pre><code>&lt;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" /&gt; </code></pre> <p>and this is the <code>OnTouch()</code> part:</p> <pre><code>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; } </code></pre> <p>thist is what I tried to solve the problem:</p> <pre><code>if (!dragStarted) { dragStarted = true; //Changed to true when OnItemLongClick called myImageView.setX(X); myImageView.setY(Y); } </code></pre> <p>But it only changes the "start point" of the image layout to the entered X and Y.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload