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?
Related
I'm new to Android programming. I'm working on an app that requires some form of animation. Please take a look at
I want an animation where a scroll rolls down at the top with this text in it as soon as this activity starts & rolls up when the connect button is pressed. I have no clue where or how to begin with the animation. Any kind of links to tutorials or posts on StackOverflow will be of much help.
Thank you for your time!
Since your question is really really broad, I'll give you a broad answer as well.
I think by "scrolling animation" you mean an animation in which a black (or some other color) area slowly covers up/reveals the screen. I don't know why would this look cool, but whatever.
Step 1
Create an animation XML file. In this file, you would specify that the view should translate downwards by x pixels where x is the height of the screen. And create another animation file. This time, specify that it should translate upwards.
If you need help creating XML view animations, have a look here
Now you have two animations - move upwards and downwards.
Step 2
Okay, now you should create a custom view. You can start by doing this:
public class ScrollingView extends View {
}
And implement all the required constructors.
Override onDraw like this:
cover the whole view with black or some other color
draw the scroll at the top of the view. The scroll should be an image like this one:
If you don't like using an image, you can draw it yourself, using code!
You can get help on this here
Step 3
In onCreate of your activity, create a ScrollingView. This view should be as wide as the screen and as high as the screen. Position the view at (0, 0) and bring it to front so that it covers up the whole screen.
Step 4
Next, apply the animation you created in step 1 to the scrolling view.
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
I'm trying to create a textview with a circular background such as shown in the image below. I have 6 other circles like this as well which come from user input.
However I run into problems if there are too many characters, it breaks the boundaries of the circle. I want to make the text go in a circular motion around the circle if the text is more than lets say 10 characters like this.
I've read other people have the same problem and the answers revolved around creating custom views. I am not that experienced with Java yet so if anyone can guide me through this I would really appreciate it.
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.
I am working on some Android animation effects. On one screen there are several background images fading in/out constantly, and there is also a text marquee. The problem is that the text marquee is kind of choppy. When the image fade in/out is disabled, the marquee is smooth, so it is likely the 2 animations are affecting each other.
I am wondering if there is a way out other than writing my own animation by using Canvas or SurfaceView.
I took a look at AnimationSet, but that is only good for combining animations for the same view.
It has been a while but here are the things I have found along the way:
To achieve smooth text scrolling animation, it needs about 50 frames per second. So it really stretches the CPU out. I tried to use a surfaceView to do both the image and text animation, and managed to get to 35 frames per second but that was not enough, the text scrolling is still a little jumpy. I read a little opengl and it looks like OpenGL ES 2.0 should be able to handle the image fade in/out in parallel ways. But did not really go through with it. Hope this helps.