Good day, I would like to ask for some advice on coding up one pretty strange graphical element.
The point is - there should be a button in the middle (green), but it should be surrounded with an animated element (blue strip around green button on a sketch).
So when user clicks the button, the blue element starts rotating, when he taps again, it stops.
any ideas on that? thanks!
Easiest way is a custom view, where you overwrite onDraw to draw exactly what you want to the canvas. Rotation can be done by keeping track of how many radians of rotation you want and using a rotation matrix on the canvas. Animation can be done by using a Handler to post a delayed message to invalidate the view.
you could make use of the Animation features of android.
make the green button as ImageButton and the blue ring as static drawable.
then create an RotateAnimation which you toggle with the button press. this animation then rotates the drawable that contains the blue ring.
here is something about the rotate animation
http://developer.android.com/reference/android/view/animation/RotateAnimation.html
Related
I'm trying to make a list of buttons bounce when a view gets visible. But I cannot get the desired result, it doesn't look similar at all.
I tried it with a bounce interpolator and an overshoot interpolator (used on a scale animation), but as said, it doesn't look similar to the desired result.
This is a gif of the desired result, it's from What's App. It's not about the circular reveal, it's only about that bouncing pop-up animation they used on the buttons (document, camera, gallery, audio, ... buttons).
I'm currently making a Java Android game and I want to rotate a car image left/right as long as the left/right half of the screen is pressed (respectively). I couldn't seem to find any help elsewhere for this, and I have no code to show, I don't know how to do it :/. Any help is appreciated!
(Oh, and also, it seems that some code doesn't show the car actually rotating - I'd like to be able to see the image rotate when I tap the screen.) Thanks!
Any help is appreciated!
I can't comment as I don't have the rep for it yet...boohoo!
But I think I have something that might help you...
http://www.tutorialspoint.com/android/android_animations.htm
The tutorial shows how to animate a view. Maybe if your Car image is a ImageView you can rotate it (if you mean move it?) by coding a game like pattern behind your buttons.
Is car moving?
No.
If left or right button pressed?
Left.
Reprint Image to the left per center pixel till left button is unclicked.
With a method then that recreates it every second in the direction of the button you have pressed?
I have a problem in my Android application : in one of my activity i had to create an incremental LinearLayout dinamically, and here i had no problem.
Once this Layout has been filled with data i want to let the user to swipe left or wipe right on it with the finger and catch this movement to do something and also this was quite simple.
My problem is that I want to move this Layout as soon as the user touch it and that is not only caught the gesture (at the moment, my Layout is fixed in the middle of the screen without any movement) ; my idea is to move the Layout with the same movement as the finger to the right or left edge of the screen and then catch the right/left swipe for doing other things. I'm not so skilled with animation so I hope in you! Thanks!
I'm coding my own multi-player game in Java; I'm in need of help with rotating a triangle polygon according to the mouse position. I have this triangle, which represents the character, the player can click the right mouse button, and a bullet will fire from the top of the ship (which ever point I assign to be the top), but I want the rotation of the player(triangle), for aiming and such, to be controlled by the mouse and where it lies on the screen. How can I go about doing this, and I want to show an animation also of it rotating in respect to where the mouse is, not just appearing there.
Extra:
One more thing, after that, I'm most likely going to want to have the mouse locked to the screen, so that it won't trail off. How can I lock the mouse to the center of the screen?
I'm using the drawPolygon method from java.awt.Graphics, maybe this is the best way?
i have a grid view and i want to apply flip rotation animation on every child of grid view.
when user touch on a grid view element it perform flip rotation animation and change image.
and i use table layout to create grid of images.
i want to perform like thisPlz check once
this performs on one(layout).
but i want to perform on a 48 elements.
any help from someone....
plz give suggestion soon..
thanks in advance....
One of the most convincing 3D flip animation I've seen is done here https://code.google.com/p/android-3d-flip-view-transition.
A lot of the other tutorials and sample codes don't produce believable 3D flips. A simple rotation on the y-axis isn't what's done in iOS.
There is also a video here: http://youtu.be/52mXHqX9f3Y
So, to flip each grid element, simple call:
ViewFlipper viewFlipper = getViewFlipperForItem(i);
AnimationFactory.flipTransition(viewFlipper, FlipDirection.LEFT_RIGHT);
Where getViewFlipperForItem is a method you implement to get the ViewFlipper on that cell. I suggest you add each cell as a ViewFlipper (or ViewAnimator) and add the images you intend to flip within the ViewFlipper (or ViewAnimator). If this isn't clear to you, let me know.
Use the below code for adding flip animation to a view in android.
final ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360f);
animation.setDuration(3000);
animation.setRepeatCount(ObjectAnimator.INFINITE);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.start();
view.startAnimation(animation);
Thanks Ephraim,
I used view flipper in my project and used that library that you have mentioned. It looks great and it help me out. Please any one who want to animate his view like rotate should use this library.
https://code.google.com/p/android-3d-flip-view-transition.