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
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'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'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?
I am interested in implementing a user interface navigation control mechanism based on a wheel shaped device (or pie chart shaped or circle shaped) in my Android app.
I would like only half of the wheel to be visible at any time. That is, only the top half of the wheel should be visible since the bottom half should be below the border of the screen. The user can then turn the 'half wheel' to show options hidden by the screen border. The visible top half should then be divided into three parts like a pie chart, so the user can press either one of them to invoke some action. The following pic should explain (it is an example with seven (A-G) options).
http://imgur.com/lNu1F
The rotation itself should not be hard, but I am having a hard time understanding how to position the wheel so that half of it is outside the actual screen. I am thinking that loading the entire wheel (but hiding half of it) is best, since that is that graphics I have and it will also allow a smooth animation when the user swipes to show some other options. How can I make Android show the wheel in this way?
Also. Any comment on how to implement the 'swipe along the wheel shape' would be appreciated.
Thank you.
So for the wheel - you are hving trouble knowing how to position the wheel because you are using XML to align you objects and would like to use something like "Align Object Center To Bottom" which does not exist.
Here is one approach that might work fine: Mask the wheel view.
Is it possible to mask a View in android?
As for swipe the wheel along, I would register the wheel to take touche events, and use only the horizontal componenet of move events to apply to the rotation of the wheel. This setup is common in audio software that uses knobs.
However if you want to have it stick to the users finger in a more realistic fashion, you will need to do the following:
When the user first touches the wheel, calculate the angle from the wheel center to the finger.
Every time the finger moves, check the angle from the wheel center to the finger - and rotate the wheel the amount that the angle has changed from the last touch event.
The formula for getting the angle between two points is this:
Float angleInRadians = Math.atan2(point1.y-point2.y, point1.x-point2.x);
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