In my layout, I am having a set of tiles(Something similar to windows phone home screen) .I am trying to flip the tile to show more content. I have taken a look at card flipping, but then it flips the entire fragment.I want it to flip a part of the whole layout.I have tried rotating it using Object animator .Here is my code..
View v = findViewById(R.id.iotd_relative);
ObjectAnimator animation = ObjectAnimator.ofFloat(v, "rotationY", 0.0f, 360f);
animation.setDuration(3600);
animation.setRepeatCount(ObjectAnimator.INFINITE);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.start();
Is there any possibility of calling another layout when it flips?
I would recommend using a ScaleAnimation, heres a good example that simulates a Card Flip, you should be able to get what you want from there.
Use Android's scale animation to simulate a 3D flip...
Related
simple question I cant find the answer anywhere, is there a way to rotate a spinner, without rotating screen or anything just create a spinner which is rotated 90 degrees?
Thanks in advance.
On API Level 11+, you are welcome to rotate any View via android:rotation in your layout XML or setRotation() in Java. Whether this will give you something that your users will like, I cannot say.
Programmatically you can try something like this -
RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
// Adding the time needed to rotate the image
animation.setDuration(250);
// Set the animation to stop after reaching the desired position. Without this it would return to the original state.
animation.setFillAfter(true);
//Then set the animation to your view
view.startAnimation(animation);
I have a linear layout with three images in it. On the click of any ImageView I want to animate the whole linear layout. The animation consists of two animations - scale and transform. I don't know how to perform this animation.
This is what I want -
Image 1 - Before Animation
Image 2 - After Animation
I want to not only animate the View but actually shift the view to its new location with animation. After animation I should be able to click the Images at their new locatoin not the old location.
How can I perform this? Please help me out.
I used nineoldandroids library to achieve this animation. I used two animation: translation and scaling.
Translation:
ObjectAnimator.ofFloat(frameCategoryScroll, "translationY", 0, -yValue).setDuration(600).start();
yValue is the the value in y axis upto which I want to translate.
Scaling:
ObjectAnimator.ofFloat(frameCategoryScroll, "scaleX", 1.0f, 0.6f).setDuration(600).start();
ObjectAnimator.ofFloat(frameCategoryScroll, "scaleY", 1.0f, 0.6f).setDuration(600).start();
i have created a surfaceView and attached an alpha fade in and fade out animation but it doesnt seem to animate.
Here is my animation code:
fadeOut = new AlphaAnimation(1.0f, 0.0f);
fadeOut.setInterpolator(new AccelerateInterpolator());
fadeOut.setDuration(1000);
fadeIn = new AlphaAnimation(0.0f, 1.0f);
fadeIn.setInterpolator(new AccelerateDecelerateInterpolator());
fadeIn.setDuration(1000);
animation = new AnimationSet(false);
animation.addAnimation(fadeIn);
animation.addAnimation(fadeOut);
//this.setAnimation(animation);
animation.setRepeatCount(Animation.INFINITE);
animation.setRepeatMode(Animation.REVERSE);
inside my onDraw method i simply call this
super.onDraw(canvas);
this.startAnimation(animation);
Any suggestions?
Thanks
A SurfaceView is a special kind of view. I'm not so familiar with the exact implementation of it, but what I understood is that it creates more or less a hole in your app, and renders the view outside of the normal framework. This causes that it's not possible to do things like animations on it (or at least limits it).
If you really want a fade in animation, I suggest you implement it yourself in your SurfaceView, or you consider extending from View instead of SurfaceView.
Android ICS (v4) added TextureView which supports animations
Because a SurfaceView’s content does not live in the application’s window, it cannot be transformed (moved, scaled, rotated) efficiently. This makes it difficult to use a SurfaceView inside a ListView or a ScrollView. SurfaceView also cannot interact properly with some features of the UI toolkit such as fading edges or View.setAlpha().
To solve these problems, Android 4.0 introduces a new widget called TextureView that relies on the hardware accelerated 2D rendering pipeline and SurfaceTexture. TextureView offers the same capabilities as SurfaceView but, unlike SurfaceView, behaves as a regular view. You can for instance use a TextureView to display an OpenGL scene or a video stream. The TextureView itself can be animated, scrolled, etc.
How do they do this? animated drawer rotation possible?
In the screenshots below, touching the 'Touch' circle at the bottom causes that circle to rotate around itself, and then 4 new navigation buttons come out that take me to other screens/activities in the app. I really want to have this in my app..
Is it a sliding drawer or some other strategy? BTW I am targeting android version 2.1
It looks as if it's mainly a animation that rotates an image. Once the animation has finished, the buttons are activated.
ImageView discsAndButtons = (ImageView) findViewById(R.id.discsAndButtons);
Animation anim = new RotateAnimation(0.0f, 90.0f, 0.0f, 480.0f);
anim.setDuration(600);
anim.setFillAfter(true);
anim.setAnimationListener(this);
discsAndButtons.setAnimation(anim);
...
void onAnimationEnd(Animation animation) {
ViewGroup buttonLayer = (ViewGroup) findViewById(R.id.buttonLayer);
buttonLayer.setVisibility(View.VISIBLE);
}
Visually, the buttons are part of the image. But the effective buttons are probably on a separate layer above the image and only made visible after the animation has finished (except for the TOUCH button).
I'm trying to do an animation that takes a button (with a custom background image and system text) and fades it out. That works fine, actually. The issue is after the animation it goes back to it's initial state. I want it to animate and stay that way.
Thanks!
AlphaAnimation anim = new AlphaAnimation(1, 0.2f);
anim.setDuration (5000);
textView.startAnimation (anim);
anim.setFillAfter(true);
That should work.
My answer is 'stolen' form android.View transparency