Can Somebody point me in the right direction, I want to animate text views like in the image below, I want to emulate the same behavior with 30 view texts showing randomly.
I'm familiar with the translation animation, what I don't know how to do is the "step" for every movement, how to handle it. And the way they appear/disappear.
Just need a hint where to start.
THIS is what I was looking for.
Code is in the sample, to modify.
Related
I'm tackling the task of an overlaying drawable over a view that animates the drawing of a checkmark as in the following video https://vid.me/MsQj
I don't have a preferred method for doing this but it's just not coming out the way I wanted it to, I tried:
Two views, each with on side of the checkmark to be revealed with an animation, however I'm stuck at the "revealed with an animation" since I can't use the circular reveal on -21
Frame by frame animation, this is the easiest but I'd hate to have 60 images for this stupid animation if it can be done programmatically
Drawing on a custom view canvas
My question would be, is there anything that can make this easier on me, or do I have to tackle it head first and just get on with it
You could create a custom View class which contains two lines defined by ShapeDrawables, one for each leg of the tick. Expose the lengths of these two lines as properties of the class, and then use Property Animation to animate the lengths of the lines.
Property Animation is flexible enough to handle pretty complex timing and sequencing of various properties. In this particular case you would probably want to use an AnimatorSet to sequence the two line animations so the second starts once the first has finished.
I ended up developing a custom View thanks to #SoundConception suggestion and finding out about ObjectAnimator which are very powerful in Android. In essence what goes on is we set a width for the first and second line that make the checkmark and using the animator change the value of those properties from 0 to the desired one.
On the setter for the property, we invalidate the View to redraw it with the new value and with a little tweaking I made a nice View that while its currently only working for my specific layout (ie it needs some more work on the offset calculation) it's able to draw an animated checkmark with some stuff that is customizable.
Precisely, you can set the line width, the color, the length and the animation time. And touching the java file, you can change the interpolator and all the rest of the stuff.
Hopefully the code, while not really commented serves as a basis for someone trying something similar.
For example the following code would generate something like this video, although not really because I was testing opacity and thinner lines, but you get my drift.
<coop.devtopia.CheckmarkView
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerInParent="true"
android:id="#+id/view"
app:first_leg_length="50"
app:second_leg_length="100"
app:total_duration="1500"
app:stroke_width="20"
app:stroke_color="#22000000"/>
Repository
Update 4/2/15
I've played with this a little further and added dynamic offset calculation (fancy way of saying centering) to the tick, meaning we can generate big checkmarks, small checkmarks, skinny or thick, reversed or straight and they will be centered in the view. Can't guarantee the same for checkmarks bigger than the container, they will likely be cropped.
Here are a few of the checkmarks generated for this demonstration, of course the animate as if drawn and the effect can be very pleasing and resource friendly. This turn out to be a pretty interesting subject after all.
I currently am using textswitcher and I am doing a slide in from left and slide out to right animation on a textview which contains a money amount.
I want to do an animation that when the number changes, it will sort of scroll to the number kind of like a slots machine.
Can anyone point me in the right direction? I would like to use android animations to do this if possible. Im sure I could just loop through, using a certain increment and change the textview along the way to the destination number but that just seems like overkill.
I'm not sure this will help, but it might be easier to do something with Canvas using the drawText() method, and then animating that drawable. Also, check the open source code for the clock here as they do similar animations
I want to display text (relatively large) and determine which character the user touches. I'd also like to embellish the text by drawing a circle (for example) over certain characters. How do I know which characters are at what location? Enforcing monospaced font would be fine if helpful programmatically.
Would it also be able to make this one line of text scroll left/right (using touch->slide) and still have touch work to determine the correct character?
A very broad question, and you've got a lot of work ahead, but here's the outline of one possible solution:
Create a custom view. ImageView is often a good base class to
inherit.
Override the onDraw() method of the view.
Use canvas.drawText() to place your text on screen.
Use paint.getTextBounds to meausure your text. See the discussion
linked below for a thorough understanding. Since you drew the text
on screen, and you measured it, you know exactly where each
character is.
Override the onTouch() method in your custom view and track the
events you need. There are many QAs here in SO on how to do this.
For scrolling the text, use canvas.translate() using the movement
you calculate in the onTouch(). Since you know how much you
scrolled (translated), you know how far your characters have moved
and can offset your touch detection to detect character touches.
Finally, since you now control all of the drawing and, your
character positions are abstract, only having meaning when compared
to a touch position, you can embellish them in any way choose.
Android Paint: .measureText() vs .getTextBounds()
Phew!
Good luck.
I have been trying to make a layout for an Android app that functions like a car Speedometer.
Something like this:
I basically want there to be 5 clickable Views across the radius of the dial, and have the dial point to the currently selected item. If possible it would be good to be able to click and drag the dial. I would also want this layout to work nicely with different screen sizes and resolutions, including tablets.
How could something like this be accomplished?
I don't know exactly how much this will help, but it goes over a similar design and shows how to place things at angles around a curve.
For each selectable view, I would also advise that you keep use keep track of the coordinates of each item, so you can use trig to calculate the proper angle for the dial to display (getting the dial to display at an angle is covered in that link).
So, you can set up OnClickListeners for each of your selectable items about the gauge, and in each instance, calculate the proper angle for the dial to spin to, and position it there using the information found in that link.
I'm not sure how much this helped, if at all, but it should at least give you an idea on creating custom Views and whatnot.
Good luck!
I have a View in an Android application, which is used to show a graphic. This View is being animated by a translation animation, specified in an XML file. In my case, the translation is moving the View from right to left across the screen.
I'd like to be able to tell where on the screen the View is when a touch event occurs, but I can't find any method which would let me do this. I've tried View.getLeft() and View.getTop(),
and I've tried getting position settings by overriding onLayoutChanged().
I can see that back in 2008 this sort of thing wasn't possible, but was planned:
http://code.google.com/p/android/issues/detail?id=321
...but can't see if it's ever made it into Android. Anyone know how I might do this?