how to Non-stop animation until the exit of activity - java

i want made animation, Until the outside of activity, animation has not stoped and And continues until the activity is running animations
my animation code :
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="30000" >
</rotate>
please send to me current code

Like this.
animation.setRepeatCount(Animation.INFINITE);

Related

Android overridePendingTransition() not working

I am trying to animate the transition between two Activities with a simple fade animation.
When I use the standard android animations it works fine, but when I define my own animations, despite them being the exact same thing, it does not work and i don't see a transition.
Working code
Method call
((Activity) context).overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
Android animation (fade_in.xml)
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#interpolator/decelerate_quad"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="#android:integer/config_longAnimTime" />
Non working code
Method call
((Activity) context).overridePendingTransition(R.anim.activity_fade_in, R.anim.activity_fade_out);
Custom animation (res/anim/activity_fade_in.xml)
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromAlpha="0.0"
android:interpolator="#android:interpolator/decelerate_quad"
android:toAlpha="1.0"/>
For some reason, unplugging my test device and coming back an hour later seems to have resolved the issue. I'm not quite sure what happened but everything seems to be working properly now.
Change your code this way
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/bounce_interpolator" >
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromAlpha="0.0"
android:interpolator="#android:interpolator/decelerate_quad"
android:toAlpha="1.0"/>
</set>

Zoom in animation between activities

I am creating an Android application. I want to open the new activity with zoom in transition. I have some buttons in my current activity. When I click one button new activity will open from the button's position. I try to use the following code. But no transition will appear. I am using the following xml and java codes.
zoom_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="800"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="70%"
android:pivotY="70%"
android:toXScale="3"
android:toYScale="3" >
</scale>
</set>
and zoom_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="800"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="70%"
android:pivotY="70%"
android:toXScale="0.5"
android:toYScale="0.5" >
</scale>
</set>
And in my java code I call it like
overridePendingTransition(R.anim.zoom_in,R.anim.zoom_out);
With these code no effect will appear. Could someone please help me to finds out what is the issue?
Try to add the attribute: android:fillAfter="true"
Like this:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3"
android:toYScale="3" >
</scale>
</set>
place both animation xml files zoom_in.xml and zoom_out.xml in res/anim
directory and start animation like this :
overridePendingTransition(R.anim.zoom_in,R.anim.zoom_out);

Making a flipping Android animation

I am very weak with animations in Android. I need to make my Fragments "flip" just 100% equal to the ViewPager animation.
Here is my slide_in_left.xml code
<?xml version="1.0" encoding="utf-8"?>
<set>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="-100%"
android:toXDelta="0"
android:interpolator="#android:anim/decelerate_interpolator"
android:duration="5000"/>
</set>
Here is my **slide_out_right.xml** code
<?xml version="1.0" encoding="utf-8"?>
<set>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0"
android:toXDelta="-100%"
android:interpolator="#android:anim/decelerate_interpolator"
android:duration="5000"/>
</set>
But this is not equal to ViewPager sliding animation. Instead, the existing Fragment exists from left and the new Fragment enters from left.
Apart from that, I need this animation to exit the existing fragment from left and new one to enter from right. How can I fix this issue?
Don't do any changes in slide_out_right.xml. But in slide_in_left.xml, just replace
android:fromXDelta="-100%"
with
android:fromXDelta="100%"
First, in your slide_out_right.xml, change
android:toXDelta="-100%p"
to
android:toXDelta="100%p"
And I think you should as well set animation for slide to right, a slide_in_right.xml and slide_out_left.xml
see FragmentTransaction#setCurrentAnimations

java animation android duration

This animation isn't animating it just instantly disappears no matter what duration I set
here is the java code and xml
Java Code:
Animation shrink =AnimationUtils.loadAnimation(Page.this, R.anim.shrink);
deleteMe.startAnimation(shrink);
XML File:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:shareInterpolator="true"
android:interpolator="#android:anim/linear_interpolator"
android:duration="10000">
<scale
android:duration="10000"
android:fillAfter="true"
android:fromXScale="1.0"
android:toXScale="0" >
</scale>
<alpha
android:duration="10000"
android:fromAlpha="1.0"
android:toAlpha="0">
</alpha>
</set>
Specify android:interpolator attribute of set tag with the value you desired.
This interpolator just moves the object from the start point to the end point (or rotation) at a steady rate.
for ex::
android:interpolator="#android:anim/linear_interpolator"
In one of my app i write this code to move a block from left to right and its working well
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false" >
<rotate android:interpolator="#android:anim/accelerate_interpolator"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1500"
android:startOffset="1500"/>
<translate android:interpolator="#android:anim/accelerate_decelerate_interpolator"
android:fromYDelta="0"
android:toYDelta="-100%p"
android:duration="3000"/>
<translate android:interpolator="#android:anim/accelerate_decelerate_interpolator"
android:toXDelta="100%"
android:duration="1500"
android:startOffset="1500" />
</set>

Android java stop a animation after completed

How can i stop a animation after it has completed?
My animation is the image fades in
code:
Java:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView imageView= (ImageView)findViewById(R.id.tCat);
Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.anim);
imageView.startAnimation(fadeInAnimation );
xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:interpolator="#android:anim/accelerate_interpolator"
android:duration="5000"
android:repeatCount="infinite"/>
</set>
Try removing the android:repeatCount="infinite", since you do not want it to repeat.
If it is a non repeating animation it will end when it is done otherwise you can just set the repeat counter to 0 to let it end after the current execution.
fadeInAnimation.setRepeatCount( 0 );

Categories