I have a textview with numbers in it. If the number was changed, i want to animate this. But this shouldn't be a fade in and fade out effect. I want to animate every single number with a vertical flip effect. Is that possible?
Animation in Android is used by Views.
So, TextView will make animation at whole.
If you want to make animation for each single number then create a lot of TextView as number digits (programmatically) and move the digits from the original TextView to each TextView. Then make animation to all these TextViews.
If the original TextView has the content (301), then you should create three TextView and set the '3' as text to the first TextView and set '0' to the second , and so on.
If you are looking for odometer like effect, there are two tutorials and code samples I know of that can help you, BUT you will need to do a custom view to achieve this effect:
http://kevindion.com/2010/12/android-odometer-ui-tutorial-part-2/
https://github.com/Vinayrraj/Android-FlipDigitView
This is the video of the final animation of second tutorial:
https://www.youtube.com/watch?v=d6-M2nN2Gzg&feature=youtu.be
Related
There is compound drawable option in TextView to avoid using a parent ViewGroup and an ImageView next to TextView. Which is neat and faster in performance as said by lint. I'm trying to do something similar. A TextView with 2 texts inside, one aligned to left, one aligned to write. Sounds strange but it will only allowed for single line TextView.
And to do that, I can extend TextView and set its gravity to right side. And inside onDraw let the super class draw on right side, and then draw text on left side.
Problem is, I'm not really sure about all this. My question is, will there be a big performance difference ? I dont have any slower device to test. I will be using this TextView inside an item layout of GridView, Item layout already have many views, it would be nice if I could merge some views to one. But again, will there be a performance difference, like noticeable by user ? And if there will be, the approach I will be using by extending the TextView, is there any problem or I should try some other way ?
Thank you
From what I have read I would imagine that you are using a custom adapter for your GridView?
If so, cant you just use TableRow and insert 2 TextViews inside that with each layout weight set to 1. Then you will have 2 columns in one row?
Just an idea.
I want to animate the text of the textview in android, i have a textview in which the text exceeds the width of the textview. I am using translate animation horizontally. It is animating the whole text view control. Using marquee property in text view does the job for me but it is quiet slow in compare to what i want to achieve. I need to know is there any way that i can animate the text of the textview (not the whole control) smoothly?
I think you mean you want a text "marquee" for when there is too much text for the TextView. If that is the case, trying the following links:
Android Marquee
TextView Marquee not working
I am making a calendar. Each day is a textview with a number denoting the day of the month.
I'd like to overlay another view which signals that there is an event on that date. See below image or think about how the google calendar app looks. How do I do this?
One way is to make the two textview inside a Relative Layout or a Frame Layout. You can look at this for reference.
You could use a TableLayout to store the TextViews in rows and colums.
A possible way of marking a special day would be changing the background resource of the specific cell with one that has a marking on it, that does not overlap with the number.
If you want more fancy stuff, you could write your custom View subclassing TextView, which handles its onDraw calls and everything else.
As far as I know you can use a RelativeLayout to overlap views.
You can try setting left drawable (android:drawableLeft="") to the TextView. OR, you can use some transparent background images with indicators drawn in top-left.
I basically have 5 text views that fill in one on top of the other. Rather then just all showing up like they do now, I want them to all come in with some animation, one after the other. Anyone have a link to a tutorial on how to animate TextView objects? only one I saw in the android docs involved using images as well as needing an image in the background.
Animating a TextView is basically like animating any other view. If you want it to show up one after one, you can implement an AnimationListener and start the corresponding TextView when the previous has finished.
Trying to do the following:
animTimeChange = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
itemTime.startAnimation(animTimeChange);
itemTime.setText("new text");
but the animation happens thru blank screen (i.e. original text is cleared, then new text appears with animation). How to avoid that blank screen?
(my TextView is part of ListView row, I've tried to use TextSwitcher - it doesn't work properly; for ViewFlipper - I am not sure where add Views there, since this is part of the ListView)
TextSwitcher is exactly what you should be using for this. Check out the API Demo for TextSwitcher.
The way you should implement this is in your ListAdapter, provide TextSwitcher views to the ListView instead of TextViews. Then you can just call TextSwitcher.setText() on the list item you want to change.
Note that you should imediately get rid of your reference to the list item to avoid REALLY messing up listview.