Scrolling Image on Android - android

I want to make an animated background on a splash screen. How can I scroll an image across the screen.
I am currently using an animation
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="10000"
android:toXDelta="100%p"
android:fromXDelta="0" />
</set>
The problem is the image size is currently set to fill the parent, so as it scrolls I can see the borders of the image. Is it possible to have an image with a size larger than the parent size. This way I can still let it scroll,without ever seeing the borders.

Related

How to I prevent squeeze of item inside layout during scale animation?

I am using scale animation in Android relative layout , where I have a button and need to scale it to small size at one end .
I have used scale animation and it works fine , but it does have an icon which gets squeezed and its shape gets altered .
I want to prevent it and let the button take its shape without affecting the icon shape when it scales from left to right.
How can I achieve this?.
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.0"
android:toXScale="0.1"
android:fromYScale="1.0"
android:toYScale="1.0"
android:duration="100"
android:pivotX="100%"
>
</scale>
It sounds like you don't really want a scale animation, you want a resize animation instead. A scale animation will act like you are resizing an image. A resize animation should just affect the layout parameters of the view without altering the size of the contents (just the positioning).
You can do this in XML with a property animator:
https://developer.android.com/guide/topics/resources/animation-resource#Property
Alternatively, here is an example of a resize animation in code:
https://stackoverflow.com/a/8162779/342745

Android Translation animation

i am trying to animate an image view by ensuring that the object appears in the center of the screen and then translates up.. to its final position. the code i used is as follows.
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:fromYDelta="400"
android:toYDelta="0"
android:duration="800"/>
</set>
This code works when u have a device of 4.7"(galaxy s3) screen size the image will appear at the center of the screen and then move to its set position. But on a screen of 4" (S advance or htc desire x) the image practically appears at the screen bottom.
So is there any way to ensure that the image is at the center of the screen heedless of the device on which the code is running?? Thanks in advance..
Use percentages instead of values to make the Animation uniform across all screen sizes.
The animation should apply its transformation after it ends
android:fillAfter="true"
The animation begins from the vertical center, i.e 50% of Y
android:fromYDelta="50%p"
The animation ends at the top, i.e. 0% of Y
android:toYDelta="0%p"
XML:
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="800"
android:fillAfter="true"
android:fromYDelta="50%p"
android:toYDelta="0%p" />
</set>
thanks for ur response..
i tried ur suggestion 's and i found that using 50%p to then in a 4 inch screen the image view is present at around 3\4of the screen. but when i use 25%p then its around the center. in case of s advance its center and in s3 its relatively center.. i guess it depends on the size of the image.(dimention)

Animations to make things go around the screen (Android)

I'm new to Android developing. I want some animations when clicking on the card and it will move around the screen and stay at its new position forever (its interactive area should change too).
At first the card is located at the center-bottom of the screen (XDelta= 50% YDelta = 70%) then it will move up straight to center of the screen (XDelta =50% and YDelta is 40%). Then it will move to its upper left (10 dp from the left of the screen and 10 dp from the top of the screen) Sorry I can't post images due to my lack of reputation.
And here's my code in res/anim/card1.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="200"
android:fromXDelta="50%"
android:fromYDelta="70%"
android:toYDelta="40%"
android:toXDelta="50%"
android:fillEnabled="true"/>
<translate
android:duration="100"
android:fillEnabled="true"
android:fromXDelta="50%"
android:fromYDelta="40%"
android:startOffset="200"
android:toXDelta="10"
android:toYDelta="10" />
</set>
And code to get it work when clicking on the card
Animation anim = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.card1);
iv_card.startAnimation(anim);
... but it just don't animate the way I want. Please help me!!!!
Check Out this (http://www.tktutorials.com/2013/07/animation-in-android-using-xml-files.html) this may help your need. Alter the translate.xml file as per your need, which is located in Res->anim->translate.xml
And solution for your posting Image. My suggestion is upload your pic in googleDrive, then change the share setting for the particular pic from private to Public on web and use the url Link to your question.

ImageView zoom animation cuts off image slightly

I am trying to implement zoom image functionality for images in the view. The view is kind of gallery view with images. I have applied the scale animation using xml and the animation works properly. The issue is when the image zooms the sides of image is cut off. I am using circularimageview as the image needs to be shown in a circle. I have tried increasing spacing between images but still the issue persists, the images gets cut off slightly when zoomed.
Can someone point out what may be the issue ?
The xml that I use for scale animation is
<scale
android:duration="300"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.15"
android:toYScale="1.15" >
</scale>
This was an issue with margins that was given around the image. I was able to resolve it by giving different margin values.

Android how to show images with Animation effect

I have 2 images of different color balls. When I press the button I am changing the image on imagebutton from image1(ball1) to image2(ball2). What I want to do is show this image change(ie ball color change with a little animation, effect that it rotates and changes color.
Question: How can I get this effect of rotating ball image1 so that it becomes ball image2 ?
Question: I want to play some sound also along with this effect. How to go about it?
EDIT: basically what I want is: image1 revolves around(180 degree) and becomes image2.
in order to rotate and hide image you will need to use a tween animation framework:http://developer.android.com/guide/topics/resources/animation-resource.html#View. You need to construct animation set that will rotate and reduce alpha of the image.
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="true" >
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0" />
<rotate
android:fromDegrees="float"
android:toDegrees="float"
android:pivotX="float"
android:pivotY="float" />
</set>
Then just use ImageView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.your_anim));
This will allow you to fade and rotate the ImageView, while revealing another ImageView below the current one.
If you want to do transition inside of a single ImageView you need to use TransitionDrawable which is a drawable that cross-fades one image to another. Unfortunately it won't allow you rotating content, so you either need to modify it, which is harder.
You could use RotateDrawable as one of the drawables in TransitionDrawable, but I have never tried this.

Categories

Resources