I'm trying to do something which seems simple. I want to have a map view, with a menu that slides up from the bottom of the screen where settings (for overlay) can be adjusted. However when I use a TranslateAnimation to affect the y position of the LinearLayout (which holds the menu), the buttons in the LinearLayout move, but there "hit area" stays in the same position as they were before the animation.
TranslateAnimation slide = new TranslateAnimation(0,0,0,0);
slide.setDuration(300);
slide.setFillAfter(true);
pullupMenu.startAnimation(slide);
mapContainer.startAnimation(slide);
I've also looked into tweening the view's marginTop value, but haven't even been able to determine how that would be done.
Any help on either of these directions would be much appreciated.
The animation in general is animating the pixels of the widget. My suspicion, based on what you wrote, is that setFillAfter() merely arranges for the pixels to stay in the destination location, not the widget itself.
If you want the animation to actually wind up moving the widget, you need to:
Register a listener to find out when the animation ends, and
Arrange at that point to modify the layout rules such that the widget actually exists in the new location
You can see a sliding pane that employs this technique here.
Related
When the user holds down on the screen, it should become transparent by their finger so that they can see the other layout beneath. When they continue holding down their finger and swipe, I'd like to create a transition where the transparency spreads outward from their initial holding location until the upper layout is gone and only the layout underneath is left.
Here are examples of the effect I'm looking to create:
I'm not concerned about the fancy movement of the purple / red squares; I'm just looking to find out how to create the swipe transition between the two layouts.
It seems like using android.R.anim.fade_in and android.R.anim.fade_out would get close to the desired effect but it would be missing the expanding circle centered on the user's finger and the transition would happen all at once instead of the intended effect of giving a peak when just held down and performing the transition only after a swipe.
you can use this npm
react-native-expanding-circle-transition
https://github.com/alexbrillant/react-native-expanding-circle-transition
I am implementing a animated book in Android and the animations are defined by an XML (not an Android XML). The images are positioned in fixed positions and when user touches in a element on the screen, the app plays a sound and animate the imagebutton, changing the image src and positions (X and Y).
I want to know how can I do that. As images dot not have the same size, I think the sprites solution is not a good way to solve it.
Its like the image 2:
Thank you
There are two types of animations:
View Animation and Proprety Animation.
The view animation can only animate View objects. It also lack a variety of animations, since it can do only stuff as scale, rotate, move... It cannot change background color, for example. Also, the dissadvantage of the View Animation is that it only change the position of where the View object is DRAWN. Phisically, it still stays in the same position. That's why the button is unclickable, after the View Animation is finished upon it.
Property Animation, in the other hand, can animate both View and non-View objects and it doesn't have constraints as the View Animation. When objects are moved, for example, with the property animation, they are not just drawn on some other position on the screen, but they are actually MOVED there.
Now, Property Animation is a lot more complex to write than the View Animation, so if you don't really need all the advantages of the Property Animation, it is suggested to use View Animation.
Source: Property vs ViewAnimation
Tutorial and SupportLybrary up to API 1: Nine Old Androids
I have a panoramic background as a sky that i want to move from left to right and then from right to left to simulate a moving clouds animation as a screen background .
This should repeat indefinitely and after goin to the right most then return back to the left most..
I have tried the following:
Animation left = AnimationUtils.loadAnimation(MainActivity.this, com.icare.kids.R.anim.view_transition_out_right);
left.setRepeatCount(Animation.INFINITE);
left.setRepeatMode(Animation.REVERSE);
left.setDuration(3000);
findViewById(id.cloud).startAnimation(left);
But this does not seem to work... any solution for that ?
I am currently setting the image to an ImageView as follows:
<ImageView
android:id="#+id/cloud"
android:layout_width="3000dip"
android:layout_height="wrap_content"
android:layout_below="#id/topbar"
android:scaleType="matrix"
android:src="#drawable/bgpan" />
how can i set the image to the screen to start from the left most like this below, so to help in the panoramic animation effect:
The best solution that is efficient and fast on all phone ranges was to actually only animate the clouds while keeping the background static.
you can also add some variable to the speed that would add some randomization to the speed of the clouds so you don't get a monotonic looping.
Implementation details and solution was taken from this answer
One thing you might be able to try is using a Viewpager object with fake drag, where you continually re-add the background to new views that get generated, while disabling user input.
This will give the illusion of what you are trying to do.
So lets say you have 4 views in your adapter, each view contains just one of the image assets that fills the whole screen, and Viewpager's fake drag pans from View A to View B, draws View C and draws View D, then it fake drags from View B to View C and draws View A again
I'm curious if that would work for you
So, much to my chagrin, I found out while testing on an earlier device, that pre-API version 11, the View class has no setAlpha nor setX methods. Can someone suggest an alternative? I'm currently moving a view around by updating its X location, and fading it in and out based on user interaction.
You may use standard Animation to implement such program logic, such as AlphaAnimation and TranslateAnimation to make movement of your View. But also you should keep in mind that original position of View at it's parent layout isn't changed (only pixels are redrawn). That means, that when user would taps on new image of View, this View would not get event, as it's Rect remains in the old position.
You could relocate Views rectangle after the end of animation, using View.layout() method with 4 positioning parameters passed there, but in this case you should consider about your layout nature, because for example if you work with LinearLayout and change the position of it sibling by calling layout() method, next change of one of UI elements size will call reaqestLayout() method and your animated View will come back at it's initial position
I am currently trying to animate a card game using an AnimationSet of Translate and Rotate animations. Although I am using setFillAfter(true) and see the card visibly move and stay in it's new position, the actual position of the ImageView is still at it's old location.
In the Google documentation it says:
Note: Regardless of how your animation may move or resize, the bounds of the View that holds your animation will not automatically adjust to accommodate it. Even so, the animation will still be drawn beyond the bounds of its View and will not be clipped. However, clipping will occur if the animation exceeds the bounds of the parent View.
This means that all of my old onClickListeners, etc are still being associated with the old position rather than the newly updated visual representation, and any new animation applied to the View occur from the initial spot, not the newly located one.
What is the best way to get the effect that I seek (a card sliding from my hand to the center of the screen, which is a different LinearLayout, and then in a later sequence sliding from that spot off the screen)?
I know what I seek is possible as the people at bytesequencing.com have accomplished this smooth animation effect in their android game "Hearts! (free)" which I discovered in the market.
Thanks!