Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to move any image any time across same layout
    primarykey
    data
    text
    <p>My requirent is to generate multiple images dynamically and perform all operation on it like drag, drop, scale, rotate.I want every image can move on whole layout. but the problem is in which area 1 image can move another image can not move. I want user can any time select any image and any image can move any where in the layout.</p> <p>My code to generate Image randomly inside onclick </p> <pre><code>LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imge = new ImageView(MultiTouch.this); imge.setImageResource(R.drawable.ic_launcher); imge.setScaleType(ScaleType.MATRIX); imge.buildDrawingCache(); BitmapDrawable drawable = (BitmapDrawable) imge.getDrawable(); Bitmap bitmap = drawable.getBitmap(); imge.setId(i++); ll.addView(imge, imParams); </code></pre> <p>My ontouch listnner :</p> <pre><code> public boolean onTouch(View v, MotionEvent event) { // Toast.makeText(MultiTouch.this, "onTouch", Toast.LENGTH_LONG).show(); ImageView view = (ImageView) v; boolean defaultResult = v.onTouchEvent(event); switch (event.getAction() &amp; MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: savedMatrix.set(matrix); start.set(event.getX(), event.getY()); mode = DRAG; lastEvent = null; System.out.println("ACTION_DOWN " ); break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); if (oldDist &gt; 10f) { savedMatrix.set(matrix); midPoint(mid, event); mode = ZOOM; } lastEvent = new float[4]; lastEvent[0] = event.getX(0); lastEvent[1] = event.getX(1); lastEvent[2] = event.getY(0); lastEvent[3] = event.getY(1); d = rotation(event); System.out.println("ACTION_POINTER_DOWN " ); break; case MotionEvent.ACTION_UP: break; case MotionEvent.ACTION_POINTER_UP: mode = NONE; lastEvent = null; v.clearFocus(); System.out.println("ACTION_POINTER_UP " ); return false; // break; case MotionEvent.ACTION_MOVE: if (mode == DRAG) { matrix.set(savedMatrix); float dx = event.getX() - start.x; float dy = event.getY() - start.y; matrix.postTranslate(dx, dy); } else if (mode == ZOOM) { float newDist = spacing(event); if (newDist &gt; 10f) { matrix.set(savedMatrix); float scale = (newDist / oldDist); matrix.postScale(scale, scale, mid.x, mid.y); } if (lastEvent != null &amp;&amp; event.getPointerCount() == 2) { newRot = rotation(event); float r = newRot - d; float[] values = new float[9]; matrix.getValues(values); float tx = values[2]; float ty = values[5]; float sx = values[0]; float xc = (view.getWidth() / 2) * sx; float yc = (view.getHeight() / 2) * sx; // matrix.postRotate(r, tx + xc, ty + yc); matrix.postRotate(r, view.getWidth() / 2, view.getHeight() / 2); } } System.out.println("ACTION_MOVE " ); break; default: return defaultResult; } view.setImageMatrix(matrix); return super.onTouchEvent(event); } </code></pre> <p>and my xml code :</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/frmlayut" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="Button" /&gt; &lt;LinearLayout android:id="@+id/ll" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/button1" android:background="@drawable/backgrd" android:orientation="vertical" &gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>can any one tell me How to move any image any time across whole layout? Do i need to make layers, If yes how to do it.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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