1

I have 3 horizontal draggable views. For example, if I drop first on the second - the second and the third must move to the right. The initial position: enter image description here

The code:

case DragEvent.ACTION_DROP:
                targetIndex = ((ViewInfo) targetView.getTag()).index;
                int lastIndex = getChildCount() - 1;
                droppedView = (View) event.getLocalState();
                droppedIndex = ((ViewInfo) droppedView.getTag()).index;

                if (droppedView == this) {
                    return false;
                }

                for (int i = targetIndex; i <= lastIndex; i++) {
                    if (getChildAt(i) != droppedView) {
                        moveChildToRight(i);
                    }
                }

private void moveChildToRight(int index) {
            ....
            TranslateAnimation anim = new TranslateAnimation(0, 200, 0, 0);
            anim.setDuration(1000);
            anim.setFillAfter(true);
            anim.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    Log.d(TAG, "Animation ended");
                    requestLayout();
                }

                @Override
                public void onAnimationRepeat(Animation arg0) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onAnimationStart(Animation arg0) {
                    // TODO Auto-generated method stub

                }

            });

            child.startAnimation(anim);
        }

OK, after drop the 2nd and the 3rd views move to the right: After drop

After that I long-press to the empty space between 1st and 2nd+3rd views, and what do I see? Drag of the 2nd view is initiated! But it's in fact shown more righter, than it can be touched. The "visual" representation of the 2nd or 3rd views are not touchable after animation: Bug

Why?

1 Answer 1

1

I realize this is over a year old, but I'll answer in case someone else finds the page.

This is how translate animation (view animation) works. It moves the object visually, but doesn't update the actually X/Y property. For example, if your views were buttons, then touching in the original area would show the click on the where the button visually is, but clicking on where you see the button would do nothing, as the actual button never moved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.