How I can reach such behavior with a smooth slider?
I want that first ImageView to increase his width and cover over second ImageView.
I tried three different approaches to this purpose.
First I drew bitmap (two bitmaps combined inside one canvas) inside the canvas of one ImageView. New position generated with ValueAnimation but it gives values with not equals intervals. During rendering the transition do jumps noticeably enough. On a good phone especially.
Second I did my own method for generating sequence numbers without intervals and but occurs another problem: phone cant render new bitmaps a few hundred times per second. If to do intervals jumps occur again.
Then I tried another way: to create two ImageView and first must smooth roll out over the second. But I can't reach the proper effect than the first picture must not stretch (image inside ImageView increased width together) but need a roll-out like on GIF.
Code of my third the attempt:
In fragment
val animation: Animation = AnimationUtils.loadAnimation(ctx, R.anim.scale_right)
imageView.startAnimation(animation)
imageView.visibility = View.VISIBLE
scale_right.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="6000"
android:fromXScale="0"
android:fromYScale="1.0"
android:pivotX="0%"
android:pivotY="0%"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
What do I need to do?
Related
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
I have a load screen/pop up screen which is a fragment which shows up whenever I call an API. I like how it looks currently, but I would like to liven it up by adding a bunch of animations to the views in the load screen.
I am using the property animation framework to good effect for
scaling and changing the alpha value(transparency) of views in their current positions.
I am now trying to get a view to animate(translate + alpha change) to it's current position in the static screen. I do not however, wish to hardcode values since this would clearly mess up the alignment of views and cause overlaps and other problems.
How do I translate a view from some point outside the screen, to it's current position in the static screen? Eg: In my static screen if I have a view that is centre aligned in the parent layout, how do I animate the view from a position outside the screen to this current position. I have tried the following but it does not work since it expects float values.
<set android:ordering="together">
<objectAnimator
android:duration="1500"
android:propertyName="y"
android:valueFrom="0"
android:valueTo="50%p"
android:valueType="floatType" />
<objectAnimator
android:duration="1500"
android:propertyName="alpha"
android:valueFrom="0"
android:valueTo="1"
android:valueType="floatType" />
</set>
I am trying to keep as much of the animation logic in xmls as possible.
After a little more research I came across the translationY(and translation X) attribute which seems to be the one I was looking for.
I have the following animation:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="100%" android:toYDelta="0%" android:duration="1000" />
<translate android:fromXDelta="80%" android:toXDelta="0%" android:duration="1000" />
</set>
I use this to animate a new view to is showing up. This animation run from bottom to top and from right to left, but the animation is like rectangle. And i wana make it to be like a triangle
In other words i want the two points (X and Y) that makes the animation to be linked by a straight line.
(Not enough rep to comment)
Is it important for it to be clickable as a triangle? What I mean is, couldn't you just load on the view a triangle-like Drawable image(there are many free icon packs around or you can create your own as .png)?
This way you SEE the triangle, while as an object is just a rectangle with a texture of a triangle. (As I don't think there is any implementation in AndroidSDK of a TriangularView, but I might be wrong!).
Another way is to use a shape drawable resource.
An easy example is how it was done by Sanket Kachhela in this post
https://stackoverflow.com/a/22043386/4482734
You could take it as a starting point.
Then again, much of this post was based on the idea you needed to interact with the Triangle, but I could be wrong and it has no meaning to do so.
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.
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.