Scale view size does not affect position of adjacent views - android

There are some circle(Custom View) in a vertical layout and I animate height of circles by tapping them .(by property animation)
but enlargement of these views do not affect position of circles before and after them.
how can I do that?

A scale animation changes the way a view it's drawn, but it doesn't affect the parent's layout. What you need in this case is to update its LayoutParams (via an animation) so that the position of any other controls are adjusted accordingly.
See this answer for an excellent sample.

Related

RecyclerView dropped down when another view above is visible, how to fix this?

The pattern of the layout is below:
---LinearLayout vertical
---LinearLayout -> contains a LinearLayout that shapes like rectangle(setVisibility-> Gone)
---RecyclerView -> below the above layout of rectangle
Originally, I set a slide-down animation of RecyclerView from the top of the window to a position where it gives enough space for the rectangle to show and when the animation ends the LinearLayout of rectangle is shown by invoking the method setVisibility(Visible)
Problem: when I set the rectangle visible, it is visible as expected but recycler view is dropped down the space as much as the rectangle's height, leaving blank space between the rectangle and the RecyclerView. I wonder what might cause this and how to fix this? Thanks!
I think you may not change the position of the RecyclerView and only set the visibility of the LinearLayout to visible. Changing the visibility will redraw the whole layout and the layout that was Gone will take its needed height, so the space between the top of the recycler view and the bottom of the layout will be (animation height + layout height) and that is why there is an empty space

Animating view: set translationY to 0 while also scaling

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!

how to calculate position in <translate> tag in android animation?

I am new to android animation and i've been playing with animation in android.
But one thing i just don't get it?
how to set position in tag.
My question is what 50%p means?
Suppose I have a button at some place 1/3 of the top. now i want to move it to bottom of the layout.then move to left bottom then at the center of the layout.
the doc says
Float or percentage. Starting X/Y offset. Expressed either: in pixels relative to the normal position (such as "5"), in percentage relative to the element width (such as "5%"), or in percentage relative to the parent width (such as "5%p").
once see this doc. This will help you to solve your issue.

Animate alpha from View's StartX to EndX (Growing horizontal Bar)

Current animation changes alpha for every part of view. I want to change the alpha through view's x and y positions. Think it as a growing horizontal bar. I have a view which is drawn by myself (canvas). Also the issue is this drawn views are in list view, they are the listview elements. So probably i need to animate ListView itself not the elements to achieve desired outcome
How can i achieve it?

How to position a view off-screen so that it can be Animated to move on-screen?

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?

Categories

Resources