Stop image-view by using animation on particular screen position - android

This is what I have done now I want to stop this animation on a particular screen position and I know during the animation it could not stop so please provide another way where I could implement this functionality in my app.
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/linear_interpolator">
<translate
android:toYDelta="100%p"
android:duration="6000"
android:fillEnabled="false"
android:startOffset="5000"
android:fillAfter="false"/>
</set>

You have to give android:fromXDelta=""
android:toXDelta=""
android:fromYDelta=""
android:toYDelta=""

Related

Define xml animation into Java

Is it possible to write slide_out_left animation using java?
Here is my animation xml.
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:duration="300" android:fromXDelta="0%" android:toXDelta="-100%" />
</set>
yes it is possible:
view.animate().translationX(_amount_).setDuration(_time in ms_).start();
So, you will have to calculate translation distance by yourself.
Note: if you translate to 0 later, after some other translations - it will move to starting position.
To complete slide in effect try to use withStartAction also.

Android Animation From Middle Of The Screen to Top And Out Of View?

I have been trying to find the answer but, have had no success. I need the XML for the animation if the Activity is currently on in the middle of the screen, and for it to slide up and out of view.
Any help would be greatly appretiated!
if I understand what you want correctly, I think you should try something like:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromYDelta="0%"
android:toYDelta="100%" />

Navigation Styles in Android

It should be a pretty simple question that I cannot find through google or the docs for the life of me. How do I change the transition style of my activity?
From what I've heard, there are the grow, left/right and up/down transitions for presenting and dismissing activities, but I don't have a clue how to implement them.
WHen you are doing:
startActivity(intent);
just put:
startActivity(intent);
overridePendingTransition(animIn, animOut);
animIn and animOut are ints that you can just define in anim resources folder for example:
slideInLeft.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="100%p" android:toXDelta="0%p"
android:duration="#android:integer/config_longAnimTime" />
slideOutLeft.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0" android:toXDelta="-100%p"
android:duration="#android:integer/config_longAnimTime" />
And when you want to return to the first activity you need to do the same but in finish method of activity:
finish();
overridePendingTransition(animIn, animOut);
You can use activity.overridePendingTransition. It takes an enter and exit animation resource ids.

Animate the activity entry

I need to start an activity in an animated way..can anyone help me?
Creating an intent and starting an activity in normal way will show new activity.I need to start it from one side,say left side..how to animate it near creating intent..
Use the following:
this.overridePendingTransition(R.anim.slidein_left, R.anim.slideout_right);
Where R.anim.* are Animation XML files in your /res/anim/ folder.
The following is an example of my slidein_left:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="500"
android:fromXDelta="-100%"
android:toXDelta="0%" />
</set>
And slideout_right:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="500"
android:fromXDelta="0%"
android:toXDelta="100%" />
</set>
What this will do is slide both activities to the left, making the new activity slide in from the left, pushing the old activity out to the right.
Also, as stated by #njzk2, please attempt to make an effort yourself before asking questions, and provide us with things that you may have already tried.

Android fade in , fade out animation issue

I'm trying to customize the animation between two activities by fading out the splashscreen and fading in the main activity.
I trying two solutions, one with fade_in.xml and fade_out.xml where controlling alphas (0-1 , 1-0) and calling everything with overridePendingTransaction(fade_in, fade_out) and one with fade and hold like ni api demo (api/app/animation/fade);
The main problem is that the splashscreen (first animation ) is losing its alpha while sliding to the right as well and the second activity is appearing as wanted.
How is possible to lock the splashscreen to its original position and just making it fading out?
fade
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="#android:integer/config_longAnimTime" />
hold
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromXDelta="0" android:toXDelta="0"
android:duration="#android:integer/config_longAnimTime" />
overridePendingTransition(R.anim.fade, R.anim.hold);
You can use the callback for .fadeOut().

Categories

Resources