ok so i have an app where the list i have is actually just a relativelayout instead of a listview so i can do more cool effects with it using touch events, so i have the layout move based on the ontouch method and the children have onclicklisteners, well now whenever i press down on a child and start to drag (in an effort to move the view) it wont and i assume because the onclick captures all movement from when the finger first hits the child whereas if i press off a child (like bare layout) and drag the view moves, so is there a way to avoid having the onclicklistener steal the ontouch event but still function? the only way i can think is to manually write my own code to detect what would be considered a press in the ontouch method but i feel like that will be too strenuous heres my ontouch method
@Override public boolean onTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); // Remember where we started mLastTouchX = x; mLastTouchY = y; break; } case MotionEvent.ACTION_MOVE: { final float x = ev.getX(); final float y = ev.getY(); // Calculate the distance moved final float dx = x - mLastTouchX; final float dy = y - mLastTouchY; // Move the object mPosX += dx; mPosY += dy; //move layout layoutparams = new LayoutParams(Fill, Wrap); layoutparams.setMargins(Scale(70), Scale((int) mPosY), 0, 0); CurrentLayout.setLayoutParams(layoutparams); CurrentSubLayout.setLayoutParams(layoutparams); // Remember this touch position for the next move event mLastTouchX = x; mLastTouchY = y; break; } case MotionEvent.ACTION_UP: { final float x = ev.getX(); final float y = ev.getY(); // Calculate the distance moved final float dx = x - mLastTouchX; final float dy = y - mLastTouchY; // Move the object mPosX += dx; mPosY += dy; //move layout layoutparams = new LayoutParams(Fill, Wrap); layoutparams.setMargins(Scale(70), Scale((int) mPosY), 0, 0); CurrentLayout.setLayoutParams(layoutparams); CurrentSubLayout.setLayoutParams(layoutparams); if (CurrentLayout.getTop() + CurrentLayout.getHeight() < HomeLayout.getHeight() - Scale(100)) { if ((HomeLayout.getHeight() - Scale(100)) - CurrentLayout.getHeight() <= 0) { Animation snap = new TranslateAnimation(0,0, (int) (mPosY - ((HomeLayout.getHeight() - Scale(100)) - CurrentLayout.getHeight())), 0); snap.setDuration(300); CurrentLayout.startAnimation(snap); CurrentSubLayout.startAnimation(snap); layoutparams = new LayoutParams(Fill, Wrap); layoutparams.setMargins(Scale(70), (HomeLayout.getHeight() - Scale(100)) - CurrentLayout.getHeight(), 0,0); CurrentLayout.setLayoutParams(layoutparams); CurrentSubLayout.setLayoutParams(layoutparams); mPosX = 0; mPosY = (HomeLayout.getHeight() - Scale(100)) - CurrentLayout.getHeight(); } else if ((HomeLayout.getHeight() - Scale(100)) - CurrentLayout.getHeight() > 0) { Animation snap = new TranslateAnimation(0,0,CurrentLayout.getTop(),0); snap.setDuration(300); CurrentLayout.startAnimation(snap); CurrentSubLayout.startAnimation(snap); layoutparams = new LayoutParams(Fill, Wrap); layoutparams.setMargins(Scale(70), 0, 0, 0); CurrentLayout.setLayoutParams(layoutparams); CurrentSubLayout.setLayoutParams(layoutparams); mPosX = 0; mPosY = 0; } // Toast.makeText(this, "boom", Toast.LENGTH_SHORT).show(); } else if (CurrentLayout.getTop() > 0) { Animation snap = new TranslateAnimation(0,0,CurrentLayout.getTop(),0); snap.setDuration(300); CurrentLayout.startAnimation(snap); CurrentSubLayout.startAnimation(snap); layoutparams = new LayoutParams(Fill, Wrap); layoutparams.setMargins(Scale(70), 0, 0, 0); CurrentLayout.setLayoutParams(layoutparams); CurrentSubLayout.setLayoutParams(layoutparams); mPosX = 0; mPosY = 0; // Toast.makeText(this, "boom", Toast.LENGTH_SHORT).show(); } break; } } return true; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en