1

I am planning to perform a Rotating Animation on a two directional scroll view (see link). I have got the effect of the 2 directional scroll view, but now when i perform a Filp3D Type of animation (see link) i am getting a rotating window !

i actually wanted to perform a rotation around x-axis animation and then perform successive animation.

My Code is :

public class MainActivity extends Activity {

ScrollView sv;
WScrollView hsv;
Animation anim;
RelativeLayout rl;
Button b1,b2,b3;

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

/*BIDIRECTIONAL SCROLLVIEW*/
    sv = new ScrollView(this);
    hsv = new WScrollView(this);
    hsv.sv = sv;
    /*END OF BIDIRECTIONAL SCROLLVIEW*/

    rl = new RelativeLayout(this);
    rl.setBackgroundResource(R.drawable.interactivemap);
    sv.addView(rl, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    hsv.addView(sv, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT /*or FILL_PARENT if API < 8*/));
    setContentView(hsv);

    Window window = getWindow();
    window.setLayout(0, LayoutParams.WRAP_CONTENT);

    /* Animation Effects : Stage I */

    applyRotation(0, 45);

    /* Animation Effects : Stage II */
    /* Still to perform ! */
}

private void applyRotation(final float start, final float end) {
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            final float centerX = hsv.getWidth() / 2.0f + hsv.getLeft();
            final float centerY = hsv.getHeight() / 2.0f + hsv.getTop();
            Log.e("center-x center-y ",centerX+"  "+centerY+"found");
            final Flip3dAnimation rotation = new Flip3dAnimation(start, end, centerX, centerY);
            rotation.setDuration(2000);
            rotation.setFillAfter(true);
            rotation.setInterpolator(new LinearInterpolator());
            hsv.startAnimation(rotation);

        }
    }, 10);
}
}

Output :
1) The output is sometimes an animation around a different axis and then it becoming invisible, as if i have not put any setFillAfter(true), which happens to present in the Flip3dAnimation Class as shown in the two directional scroll view link.
2) The Animation comes and persists but only the original window is rotated in the 3d space, as if a card has flip 45 degrees !

I need the second Output with any window restrictions, as i have used a scroll view (2d), i want to be visible like a 2d plane as in a game like AOE (Age of Empires, seriously, people play games :D), or for non-games, a open 2d surface.

Please guide me for achieving the same, also please direct me to some source code which performs complex 2d animations for API-8 or 9.

Community
  • 1
  • 1
Sri Krishna
  • 302
  • 1
  • 2
  • 14

0 Answers0