Translation animation of large image from top to bottom Android - android

I'm trying to develop a splash screen with a large image scrolling (Animating) from top to bottom.
I dont think using ScrollView would be good since I dont want the user to scroll the image.
This is what I would like to achieve:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromYDelta="-100%p"
android:toYDelta="100%p"
>
</translate>
</set>
create this animation as slidedown.xml in an anim folder in the project and use the code below in the java file that has the view.You may change the values of "android:fromYdelta" according to your need.
myImageView.startAnimation(slidedown);

For example if your imageview is 250 px use :
ObjectAnimator.ofFloat(myImageView, "translationY", 250);
And in xml set on your imageview :
android:translationY="-250"

Related

Android Animation to be done from bottom towards up but will be invisible in center

http://framerjs.com/examples/preview/#carousel-onboarding.framer like this i have to develop,please check this link only on Chrome .
What I'd do is an Animation Resource File (a file in the res>anim directory of your project. If you don't have the anim directory you can simply create it.).
The content of this file (named as you wish, like myanimation.xml) should be:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0" />
<translate
android:fromXDelta="0"
android:toXDelta="0"
android:fromYDelta="0"
android:toYDelta="-50" />
</set>
The tag means that the object will animate from completely opaque (1.0) to completly trasparent (0.0)
The tag means that the object will animate from its starting position to the same X coordinate and 50 pixels above.
To use this animation from an Activity simply use:
Animation myAnimation = AnimationUtils.loadAnimation(this, R.anim.myanimation);
myAnimation.setDuration(millisecYouWant);
viewIWantToAnimate.startAnimation(myAnimation);
for more complex animations look at this link: http://developer.android.com/guide/topics/resources/animation-resource.html
EDIT: I think the question should have more details, in this case something like the piece of code where you want to applicate this animation, or what you want to animate (like an ImageView, or a Layout ...)

Android - animate View object - specific XML <set>

I'm new to Android application programming, and using search i've so far solved all of my problems (stackoverflow being one of the best search hits !)
Now i have a problem i don't know how to solve :
When separate animations are required, i could do it in code, but using XML files in anim folder would be much better for me.
Is it possible to play an animation of a single <set> inside XML file ?
I mean is it possible to "compress" animations from mulitple XML files into one file and still use them individually ?
Example for normal animation of TextView widget :
TexView exampleTextView = (TextView) findViewById (R.id.example_textview);
Animation animatorSequence = AnimationUtils.loadAnimation (this, R.anim.example_animation);
exampleTextView.startAnimation (animatorSequence);
XML code with two example blocks that i would like to use separately
<?xml version="1.0" encoding="utf-8"?>
<!--first independant animation segment -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<translate
android:fromXDelta="-100%"
android:toXDelta="0%"
android:duration="1400" />
</set>
<!--second independant animation segment -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<translate
android:fromXDelta="0%"
android:toXDelta="100%"
android:duration="1400" />
</set>
You can't.
But you can divide them to multiple files, load the in run time and add them all to a single AnimationSet (You can also define the empty set itself in a XML file so you won't have to configure it programmatically).

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%" />

Android Alpha Fade in Animation Issue

I have an ImageView element that I create in my code and place inside of my RelativeLayout. I set this image to be Invisible to start off with using the following code:
arrow.setVisibility(View.INVISIBLE);
I then defined a Fade-In Alpha animation via XML:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:fillEnabled="true"
android:fillAfter="true"
android:fillBefore="true">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:startOffset="100"
android:duration="300" />
/set>
To run the animation:
I simply call the following to start the animation
myview.startAnimation(myanimation);
The issue I am seeing is that my animation causes the ImageView to flicker in at full visibility and then go through the animation of alpha 0 to 1. How do I fix this? I can't set the initial alpha value to 0 because the alpha animation is based on percentage and not absolute alpha value. (ex: 0*current value to 1*current value)
Any help would be greatly appreciated.
I think the problem is, with this line of code:
android:fillBefore="true"
Here, Try this code instead, it works for me :
<?xml version="1.0" encoding="UTF-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fillAfter="true"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
If you are using animateLayoutChanges in your layout file in combination with the animation, toggling the View visibility will result in two animations running and the view flashing or blinking. Setting view visibility causes the layouts animateLayoutChanges to run and to fade the view in once and then the animation you created causes a second animation to run as well.

Android, make an animation text scroll up on the screen like first part of Star Wars

I'm trying to create an animation in my android app.
I want the animation like the credits of Star Wars the movie, where a text goes up gradually. If there is another way to do it than I'd like to know.
Try this :
Put this piece of code in an xml file in res/anim/animationfile.xml
<?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:duration="5000" ---> set your time here
android:fromYDelta="-100%p"
android:toYDelta="100%p" /> </set>
Now to set the animation, do this :
Animation translatebu= AnimationUtils.loadAnimation(this, R.anim.animationfile);
tv.setText("Some text view.");
tv.startAnimation(translatebu);
This is how you do it roughly.
here is a very good example of animation for u
http://android-er.blogspot.com/2012/02/various-effect-of-interpolator-in.html

Categories

Resources