Android video-like animation, how to create? - android

In this mock up, see the screen where it said "Decrease Traffic", the traffic light pops up from below.
https://dribbble.com/shots/2106573-Intro-App-Interaction
I'm wondering how to create that effect on Android, if possible, any library to do that. Thanks

you can achieve this with Android Property Animations
in your example it seems to be a scale animation from 0 to 1 in x and y direction.
you can also combine different animations to get such or other effects.

My guess is that these kind of animation are to develop with a 3rd party program, and are not done by Android itself.
This way you have a ready-to-instantiate file (.gif maybe?) that you just call when the view pager is switched.
Looking also to the other animations in the example (look # "Meet New Friends", how every circle pops by himself) I think this was the used approach in your example-link.
If you are anyway looking for something that would look like what is done there, I'd suggest you start playing around Animator objects (and its subclasses like Value/ObjectAnimator) to animate the view you want.
This can be done also via XML files, describing the animation you need.
An important role in this do-it-yourself animation is played by Interpolators , who give you the chance to further customize the animation in an easier way (take a look at OvershootInterpolator, which lets your animation go a bit after the destination value you set, just to turn back later, giving you a "blob" effect. This might give a better idea what I'm meaning)

Related

Applying physics to Android View objects

I currently have an android application that utilises the native android views for the UI (e.g. imageviews/buttons etc)
Although this app is not a game, nor requires any heavy graphics or OpenGL, I would like to incorporate a little physics-related interaction. Nothing too significant but maybe display minor collisions/bounces, deceleration/acceleration or possibly friction.
Is this possible to simulate either within the android framework or using an external physics library like jbox2d without having to utilize an entire game engine (like andengine, libgx etc).
P.S. this is for API 15+
Thanks all.
As long as you can set/update the position of the UI elements every frame (e.g. with View.setTranslationX()), you can do it.
Animating the UI by hand would mean keeping a mapping between the UI elements and the physical (e.g. jbox2d) bodies that correspond to them. Then you update the respective positions of the UI elements to what the simulated bodies have each frame (such as body.getPosition()).
In event-driven apps, something like a Timer object is useful for scheduling the physics updates.
The easiest way (not that flexible) is using ViewPropertyAnimator.
With it you can animate properties even in parallel. Maybe you want to change a view margin from the parent left. You can change that margin there, setting up the time to move and else. Some examples on this blog
ValueAnimator is other alternative, which uses the AccelerateDecelerateInterpolator by default and you have to provide the code that changes the property you need. This official guide may suffice to get them working.
what you want is quite impossible - your options are:
you may fake stuff like bounces with animations
you can implement a whole new ui lib
you use openGL what i would do
I think this can be achieved, at least at some point.
You have access to a pretty complete Animations API. This last, together with some view bounds, distance, and probably device orientation calculations, can be used to simulate almost all the cases you mentioned.
You can create Accelerate/Decelerate, form change... and almost whatever animation you want.
How you can achieve what you are asking for:
Having different animations, one after another, creating and applying them dynamically depending on the view item state. And by state, I mean the "physical state": falling, collisioning, in touch with another view, and so on...

I want to make a rectangle slowly extend across the screen taking exactly 1 second in android

Basically, I am making a rectangle that represents charge on your weapon. I want a green rectangle to advance over a red one after a certain amount of time. My issue is the timing. I have no clue how to do any timing anything in android.I'm fairly new so don't use too many things I might not understand. All of this is within a view. I researched threading and handlers, but just got confused.
Check out View Animations if you want to support pre 3.0 without using a library. OR Property Animations if targetting 3.0+ is ok.
I have more experience with the View Animations and I can tell you that the Scale animation is the one you'd be looking for. Make your X scale to 100% its size perhaps would get the job done.

Android: Graphic slider index

I need to make a slider index like this:
(In this case it's indicating that the current index is 3).
Since it doesn't seem to be a finished solution, I have to make a custom one.
2 Possibilites come to my mind:
Create a custom component and draw/update the circles using onDraw. Only "geometric" drawing. But it has limitation in effects. Maybe I want a shiny circle or something, then that will not work. On the other size resize is easy.
Use bitmaps. But I don't know if this is maybe expensive... (If I have 30 or more). And from some count I have to scale down, and this could not look good anymore.
Or maybe something else?
Can anyone advice me what's the way to go to do this...
Thanks.

Android and slideshow transitions

I am trying to write a simple slideshow with various transitions between images.
I would like to have various transitions like fade in, fade out, slide left/right which could probably be done with android's API Animation. But I would also like to have more complex transitions like checkerboard left/right, box in/out, circle in/out, curtain, spiral, split horizontal, and so on which I believe can't be done with Animation.
I know that names of transitions like I named them above are not enough to know exactly how the transitions should look like, but I think you get the general idea.
So, my question is:what should be used to achieve those effects/transitions? I am not asking for the code (though some links to examples would be great of course), but more generally what should I be using? OpenGL? Regions? Clip Paths? BitmapShaders?
I just don't feel like spending a week investigating this, when I am sure you guys know the answer ;)
If possible I would like to avoid OpenGL since I haven't used it. On Android 3.0+ devices I will use hardwareAcceleration="true" in Manifest, and on devices less than 3.0 I could limit to simple slide in/out, fade in/out if necessary (read: if other transitions would be too slow not using openGL).
Check view animation and property animation.

Custom layout in Android: scrollable graphic with selectable elements over top

I'm fairly new to the Android platform and was wondering if I could get some advice for my current head scratcher:
I'm making an app which in one view will need an image, which can be scrolled on one axis, with a load of selectable points over the top of it. Each point needs to be positionable on the x and y (unlikely to change once the app is running, but I'll need to fine tune the positions whilst I'm developing it).
I'd like to be able to let the user select each point and have a graphic drawn on the point the user has selected or just draw a graphic on one/more points without user intervention.
I though for the selectable points I could extend the checkbox with a custom image for the selected state - does that sounds right, or is there a better way of doing this? Is there any thing I can read up on doing this, I can't seem to find anything on the net about replacing the default images?
I was going to use the absolute layout, but see that it's been depreciated and I can't find anything to replace it.
Can anyone give me some code or advice on where to read up on what I need to do?
Thank you in advance
This really feels like something you should be doing with the Canvas and 2D graphics, rather than trying to twist the widget framework to fit.

Categories

Resources