First of all not duplicate of : Alternative to overridePendingTransition() - Android
I want to scale an activity (exit) with a pivot point. The problem is that the xml pivotX & pivotY values use pixels which makes things difficult. So overridePendingTransition() is not really helpful because it only uses a xml animation.
So I want to animate the scale-exit of an activity (from 1f to 0f scaling rate) with a pivot of 50dp of the right of the screen and 100dp from the bottom of the screen.
Any ideas?
You have to start a transparent Activity and make your animation from here
Look at Android Developers Activity Animation where they explain the old custom/manual Activity Transition.
Related
I know how to make a typical animation using Animation API in Android. But I don't know how to make this:
It is simply a textview inside a ring while the ring is animating and the textview is just in a fix state. Note that the ring thickness is not changing while scaling.
Assuming you have your ring as a view already, you simply create an AnimatorSet with two ObjectAnimators that changes the scaleX and scaleY of the ring view. How far to scale depends on how far you want the ring to extend out or in.
Make sure you set the pivotX and pivotY to be the center of the view.
Then, simply have it repeat.
I have a view that I want to animate- scale it to a bigger size and at the same time move to the very top of the screen, just below the notification bar. The problem is however, at least I think, that the translationY complies with initial view scale and moves it to the top of the screen, but as the view grows, it gets cut off at top.
This is the code I'm using
image.animate()
.alpha(1f)
.translationY(0)
.scaleX(6f)
.scaleY(6f)
.start()
Any simple solution to this? A way I could calculate the real value I should set translationY to (based on scale) in order to be positioned correctly? Any help appreciated!
Within Android, I'm trying to move a TextView from outside the parents bounds into view, but the contents never shows up, or remains clipped if it was partially within the bounds already.
Initial situation at start
Situation after animation
(Below this is another view, that was completely out of bounds and isn't drawn either)
I have 4 TextViews below each other in a custom Object extending RelativeLayout. Based on a percentage the top 2 should move outside it's bounds and the bottom 2 should move in (from the bottom).
I use the following code to update the properties of each TextView. In this class each variable **positionY* is filled with their initial position from the layout-xml. effect is percentage between 0 & 1. The animation works, but the views aren't drawn again.
public class ActionBarTitleView extends RelativeLayout {
public void updateTransition(float effect) {
float height = getHeight();
titleView1.setY(title1positionY - height*effect);
detailView1.setY(detail1positionY - height*effect);
titleView2.setY(title2positionY - height*effect);
detailView2.setY(detail2positionY - height*effect);
invalidate();
}
}
What I tried
After some researching I found a few hints what the issue might be, but so far none of the tried options had any effect. Below is a list of things I've found on SO and tried.
Calling invalidate() on the RelativeLayout - No effect.
Invalditing the TextViews - No effect.
clipChildren = false for the RelativeLayout - No effect.
setWillNotDraw = false for the RelativeLayout - No effect. (onDraw is being called)
I haven't tried to solve this with a ScrollView, but I don't want to really, cause that adds another layer in the hierachy for something pretty small.
I thought I understood the drawing logic, but perhaps I'm missing something, so I hope someone might be able to point me in the right direction.
What I ended up doing (September 3rd)
Since no real solution was offered, I tried again and came to the following "fix". I set both second labels to Visibility.GONE, but within the original bounds of the container view. Then when I start the animation, I set their correct values, then move them outside the bounds and finally setting Visiblity.VISIBLE. When the animation progresses the labels roll into view as supposed to. So a fix to the issue, but no real explanation why the TextViews aren't drawn again...
I'm developing an alternative home application which fits on one screen.
Currently I have one activity ,which has the height and width of the phone screen,in which I try to set default wallpaper as background.
I use this code to do this:
getWindow().setBackgroundDrawable(peekWallpaper());
The problem is that it stretch the wallpaper to make it fit in one screen, so my wallpaper becomes completely flattened.
I found a workaround to avoid this, I extends drawable class and overide the method setBounds in order to avoid the stretching. But by doing this, I only see the left top corner of my wallpaper. So I would like to center it.
How can I do that ? Am I on the right way to do it ?
I have seen some methods in WallpaperManager class to move wallpaper :
setWallpaperOffsetSteps(float xStep, float yStep)
and
setWallpaperOffsets (IBinder windowToken, float xOffset, float yOffset)
But I don't find any sample of code on how to use IBinder parameters, can it be usefull on my case ?
Thx in advance.
I have a RelativeLayout filling the screen and a couple of ImageView positioned on it using LayoutParams margins. These ImageView are animated in different ways, and in one case I want an image to "fly in" to the screen from the right.
Unfortunately, if I set leftMargin for that ImageView greater than the width of the screen, it does not appear (or appears cropped if it partially visible at the start of animation).
I tried setting width and height of RelativeLayout to be bigger than screen size - it works, but only partially: if the image is positioned completely off-screen, it does not work, and if the image is partially visible, it is not cropped, but that works only for right and bottom sides.
So, my question is this: how to position several ImageViews on and off the screen so that I can animate them using Animation?
In the end, I used a trick: I combined AnimationDrawable and view animation. I did the following (assuming that the animation has to run T milliseconds):
Position that ImageView on-screen.
Set as its background an AnimationDrawable with following frames:
empty Drawable: 1ms,
normal Drawable: Tms.
Change view's animation to this:
jump to off-screen position (translation with duration=1ms),
do normal animation.
This is probably a good place to start looking for those who would use Fixpoint's solution.
Android — How to position View off-screen?