Search code examples
androidanimationclickobjectanimator

How Click on Animated View or Object in Android?


I have an ImageButton with TranslateX Animation Right to Left like Merquee, So it animated right to left. Now when i click on that nothing happened. Actually click is not perform and click only perform on real position of imagebutton.

what to do any suggestion? greatly appriciate... Thanks


Solution

  • Use ObjectAnimator(For later version then Honeycomb) for Animatinfg Your Objects, You can use follwing code for references:

    RelativeLayout layout = (RelativeLayout) findViewById(R.id.relativeLayout1);
        Display display = getWindowManager().getDefaultDisplay();
        int width = display.getWidth();
        ObjectAnimator mover = ObjectAnimator.ofFloat(layout, "translationX",
                width, -width);
        mover.setDuration(10000);
        mover.setRepeatMode(Animation.INFINITE);
        mover.setRepeatCount(Animation.INFINITE);
        mover.start();
    

    If you Are Using Api lower Then the HoneyComb(Like Gingerbread) then Use this Library: http://nineoldandroids.com/

    It will Working As its Working in my devices.