android - How to stop other images to move while dragging of one image -


In my application, I am able to overlap images with each other, when I draw an image from the group of images to the left And the correct pictures are also moving on the screen. How to restrict it, below is my code

  int card [] = {R.drawable.c1, R.drawable.c2, R.drawable.c3, R.drawable.c4, R Drawable.c5, R.drawable.c6, R.drawable.c7, R.drawable.c8, R.drawable.c9, R.drawable.c10, R.drawable.c11, R.drawable.c12, R.drawable C13}; Image view [] images = new image view [cards.length]; For (int i = 0; i   

You have a small snippet to go to i have some images Added to layout . Drawing is done in canvas for better performance of dragging. You just need to handle layout parameter update MotionEvent.ACTION_UP event:

  private image view [] images; Private boolean mDragging = false; Private Reit mImageRect = New Rect (); Int MX = 0; Int ME = 0; Private bitmap ambitmap; Private image view mImage; @ Override Public Boolean On Touch Event (Motion Event Eve) {Switch (Evoke Action)} {Case MotionEvent.ACTION_DOWN: MX = (ev.getX); ME = (int) ev.getY (); For (image image: images) {image.getHitRect (mImageRect); If (mImageRect.contains (MX, ME)) {mDragging = true; MImage = Image; Mbitmap = ((bitmapraudable) mImage.getDrawable ()) .getBitmap (); MImage.setVisibility (View.GONE); PostInvalidate (); break; } } break; Case Motion Event Action_ MOVE: If (amragging) {mx = (int) eve.tex (); ME = (int) ev.getY (); PostInvalidate (); } break; Case Motion Event Action_up .: if (underwriting) {mDragging = false; MBitmap = null; MImage.setVisibility (View.VISIBLE); MImage = null; } break; } Return super. Tontivent (Eve); } @ Override protected zero dispatch dow (canvas canvas) {super.dispatchDraw (canvas); If (mbitmap! = Null) {canvas.drawBitmap (mbitmap, mx, my, null); }}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -