want a ImageView to come from upside down - android

i have a window and a imageview in it and i want the imageview to come from upside down animated effect how i do that
ImageView img_sliding=(ImageView)findViewById(R.id.img_sliding);

You have to write your own translate animation. a very good tutorial could be found here..
Here is a litte snipped that you can use and adapt it to your needs:
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="100%"
android:toYDelta="0%"
android:duration="300"
android:zAdjustment="top"
android:fillAfter="true" />
create a new xml file in res/anim and then set the animation to your imageview like this:
Animation anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.YOURANIMATION)
and set it to the iamgeView
imageview.setAnimation(anim);

Use a scale animation to scale from -1 to 1. This should have the effect of flipping the imageview

Related

How to create an animation in a splash screen?

When we open a app we get different type of animated object or people moving around in the splash screen of an app for example like a person running while the app is loaded or the name of the app falls and a guy sits on it clicking photos.
How can we create one and what type of software do we use?
Can you suggest me some tutorials to follow?
use gif
OR
use Animation :
Ex) Awesome-looking customizable splash screen : AwesomeSplash
paste this xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/bounce_interpolator" >
<scale
android:duration="600"
android:fromXScale="1"
android:fromYScale="0.5"
android:pivotX="50%"
android:pivotY="0%"
android:toXScale="1.0"
android:toYScale="1.0" />
<alpha
android:duration="600"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
and on the splash screen
Animation animation = AnimationUtils.loadAnimation(contex, R.anim.blink);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE);
animation.setDuration(700);
and use this Animation like
final ImageView splash = (ImageView) findViewById(R.id.btnrecievecall);
splash.startAnimation(animation)
You can also use your own created gif images to show on the imageview at splash screen through Glide image loading and caching library.
Like :
ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.gif_image).into(imageViewTarget);
1.. use gif file
or
2.. First using set animation effect, and after direct using this image splace screen.

Rotate animation to an ImageView in FrameLayout does not take effect

I have one ImageView in FrameLayout, and apply rotate animation to it. However, the animation does not take effect.
The animation resource file anim_blog.xml(located in res/anim):
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/linear_interpolator" >
<rotate
android:fromDegrees="0.0"
android:toDegrees="360.0"
android:pivotX="50%p"
android:pivotY="50%p"
android:repeatCount="infinite"
android:duration="1200" />
</set>
The code in Activity is listed below:
Animation rotateAnim = AnimationUtils.loadAnimation(mCtx, R.anim.anim_blog);
rotateAnim.setDuration(Integer.MAX_VALUE);
mProgressIV.startAnimation(rotateAnim);
You are setting animation duration too large, change it as follows :
Animation rotateAnim = AnimationUtils.loadAnimation(mCtx, R.anim.anim_blog);
mProgressIV.startAnimation(rotateAnim);
please try what has done successfully from my end:
ImageView image = (ImageView)findViewById(R.id.imageView);
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.anim_blog);
image.startAnimation(animation);
I created example here, you can check it out.

Android ImageView Animation: moving an ImageView over other views depending on their position

I need a Java (Android) code for animation to animate (move) ImageView3 from ImageView1 to Imageview2. I need the center of the ImageView3 to match the center of the ImageView1 at start and center of the ImageView3 to match the center of the ImageView2 at the end of the animation. I made a gif to show what exactly I want to achieve
Copy paste this code in your animation file. Adjust the percentages to your needs.
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromYDelta="0"
android:toYDelta="80%"
android:fromXDelta="0"
android:toXDelta="80%"
>
</translate>

How can I control the animation speed in android

I have a music app and the music notations perform an animation from right to left, I want to control the animation speed, while they are performing.Can anyone please help me for that?
My animation layout is:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="500%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="10000"
android:fillAfter="true"
android:repeatCount="infinite"/>
And my code to perform the animation is:
Animation am=AnimationUtils.loadAnimation(this, R.anim.note);
music1.startAnimation(am);
set your android:duration with this help you can control your animation speed
android:duration="300"
change in the duration will control the speed of animation in your file.
android:duration="10000" // here you have to change the time in milliseconds.
you can implement onTouchListener to control your animation speed at the run time. inside touch listener event put coding to change your animation duration.
From official documentation:
ValueAnimator animation = ValueAnimator.ofFloat(0f, 100f);
animation.setDuration(1000);
animation.start()
In your case:
music.setDuration(setValue);

Animation to move view with 200dp upside/downside

I want to make animation to move layout exactly 200 dp up for android application. So far I tryed many ways and cannot make it to work on multiple screen sizes.
This is xml file that im using:
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:fillAfter="true"
android:interpolator="#android:anim/linear_interpolator"
android:duration="10000"
android:fromXDelta="0%" android:toXDelta="0%"
android:fromYDelta="0%"
android:toYDelta="-400" />
</set>
I tried this also
final TranslateAnimation moveUpAnimation = new TranslateAnimation(0, 0, dpAsPixels, 0);
dissapearAnnimation.setDuration(20000);
The problem is that this layout has dinamic content so its lenght is changing, so % of its lenght to move up is not working for me . Thanks in advancce !
Take a look at ViewPropertyAnimator.
yourView.animate().translateY(getResources().getDimensionPixelSize(R.dimen.animationHeight)).setDuration(yourDurationInMs);
In your dimension resources:
<dimen name="animationHeight">-200dp</dimen>
What kind of layout are you using? To animation you sholdu use relative / frame layouts.

Categories

Resources