How can i show progress of red and green colors towards each other from two extreme end points. I tried to do animation for it. How to use ValueAnimator to progress them each other.
Could you provide at least some code you used so far, to start with?
And could you clarify (e. g. a sketch) what kind of animation you want to achieve? The rectangles getting wider and finally connecting each other? I canĀ“t imagine what you want.
Related
I've searched and searched, but couldn't find what I was looking for...
There are many ways to animate in android and being a newbie I do not know which solution to choose for my app.
Here's what I want to do:
It's an animation of rectangles moving slowly (takes ~10 min to cross the screen) from top to bottom through the screen.
Each and every one of the rectangles is clickable, through some listener, and does something.
Two or three buttons at the bottom of the screen (which I already created as floating action buttons) do not move and float "on top", i.e. the moving rectangles pass underneath them as they move down the screen.
The animation can be stopped and then resumes by the action buttons mentioned above.
Newly appearing rectangles appear on top as they " emerge" slowly from the top of the screen, i.e. when part of them is still outside, as they reveal themself by moving down.
I want this to be simple and robust.
How should I implement this, and please explain why...
As a loop?
A separate thread? Of so how?
I would like to understand the rationale behind every approach...
Thanks,
Julius
In one my project i want to use a spinning wheel.
No. of sectors, color and text used to fill those sectors will come from API response.
I need to create a circle(Center aligned in the screen) dynamically and split it according to the number of sectors and fill text and color. Then Spin the circle for 2-3 seconds and stop it at a position (Arrow pointing at bottom of circle). This position also from Webservice response.
What will be the best way to achieve this.
Currently iam using the below project as a reference
https://github.com/anupcowkur/Android-Wheel-Menu
Here the pointer is positioned at top. how to shift it at the bottom of circle. And also how to apply the spin animation (Mentioned above)
Thanks in Advance !! :-)
I'm experiencing the following problem with animations in Android: I want to animate some boats moving from right to left in and out of the screen. These boats have text written on them and these texts have to move along with the boats. What I implemented is a layout with 4 boats and animate them 1 length to the left with a translate animation and then repeat this animation. The boat in the center has a certain text written on it and the boat to the right has the second text, so the user can see it as the boat moves into the screen. However, when the animation repeats itself, the text from the right boat is drawn on the new center boat, which causes a flickering effect while the boat animation looks fine. Please see the video for an example. This video was recorded from the emulator and it exaggerates the problem a bit, on actual devices it's more of a flickering effect.
I've tried several possible solutions found on SO, such as .setFillAfter(true) and delaying the drawing of the next repetition, but none of this solves the problem. Does anyone know a solution to this problem?
Hey I was wondering if there is any way to do this without going insane with lil buttons built up to make it but basically what I want to do is make two curved buttons around a circle one, is there any way of doing this?
Hers an example of what I kinda want, sorry for how crude the drawing is.
There are two parts in answering this question : how to have buttons looking like this, and getting the touch on the areas you draw.
For the first part, you can use a FrameLayout or a Relative Layout to draw your buttons exactly where you want, and custom images as background (maybe for the circle you can make a ShapeDrawable).
For the second part, it can be very simple : if the Circle (biggest button) is on top of the other two, then this can be ok. But I guess the touchable area on each button will be a rectangle.
Another way to do this is create a custom view, handle the Touch events yourself and based on the X and Y, detect which part has been touched
I'm working on a game that in some ways is similar to Tetris (imagine a 2D array of colored squares that sometimes move around)
I am trying to animate the individual squares so they will smoothly slide down from coordinate to the next. Since I wanted to use Android's built-in tweening feature, the animation has to apply to the whole View (rather than parts of it). This doesn't work well for me because I only want some of the colored squares to slide down, and the rest of them to stay still.
The (theoretical) solution I came up with to resolve this is to make 2 Views, layered directly on top of each other. The top view is for animating squares when they need to move, and the bottom layer is for the static squares. The animation-layer is transparent until I am ready to animate something. I then simply turn on the colored square in the animation-layer, tween it to the new location, and turn it back off when done. In the same time span, the static-layer just turns squares on and off at the right time to make the whole thing look seamless to the end user.
The proposed solution is just a theory, since I haven't been able to make it work correctly yet. Since I have been having trouble, I was wondering if this is even the best way to solve the problem? Perhaps there is a more elegant solution that I am over looking? Anyone know of a better way?
If you just want to animate a single element check out the namespace android.view.animation.Animation. You can also use Drawable shapes and draw them directly. Finally, if you want a simulation then you will have to look into threading. Basically you will create a timer to update the canvas for you based on an interval. There are some other view canvases you can use as well like the GLView canvas.