I have a TextView which I rotate.
The rotation causes the text View to be a little bit translated.
Because of this at the same time I want to do 2 transitions in x and y direction.
I know where the View should be but I don´t know where it is and when one wants to do a translation I only can tell how far I want to transpose not what to.
myTextView.setTranslationX(60);
that is the function I know and every other way you have to give how far not what to.
I always want to translate the view to left corner of my device.
** I know that the first thing that comes to mind is to get the distance between edge of screen and edge of View but that doesn´t work because the rotation hasn´t finished and I can´t wait for it because I want it to look smoothly animated.
Related
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.
I am rotating my View using SetRotationX. However, since this is a scroll view, I want the rotation to always be performed on the visible part of the screen (the middle of it). The default behavior is to rotate it around the middle of the view, which sometimes is out of screen.
I've noticed the "transformPivotX" property, but I'm creating my view on the fly, not from the resources.
Does anyone know how to do it (programmatically)?
Thanks,
yakobom
OK, that was stupid... I dont know how I missed it. It's "SetPivotX"...
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);
I want to rotate an Android View with API level 8. For example, I want to rotate an EditText by 90 degrees so that when the user enters text into a left justified EditText, the first character is at the bottom (rotated 90 degrees) and subsequent characters are entered upwards.
I first tried using an animation with duration of 0, but you still see the field rotate. Unfortunately, this is a non-starter. If I could find a way to hide the animation completely, this method looks to be the simplest.
I then tried rotating the canvas in onDraw which works great for square Views but not so great for ones that aren't square (and I don't control the dimensions of the EditText). I tried various attempts at clipping and translating the canvas, but while I could get the cursor to come into view at the start of text input, it would do weird things once somebody started entering more content (usually the content would disappear out of view).
I also tried making the View square in onMeasure, then rotating the canvas in onDraw, then putting the View dimensions back in a subsequent onMeasure. The first two steps worked great. But the third step produced similar results as described above: things looked ok until the user started entering more text at which point the field text did strange things (usually disappearing).
Has anybody been able to successfully rotate a non-square Android View (an EditText for example) without animation, and with API level 8 or lower?
I've spent a pretty good amount of time trying to rotate a view exactly on API level 8 and I think it's impossible to make it work properly. FYI, it doesn't work correctly on android 3.2 either although there's a setRotation(int angle) method in the View class. This won't work correctly at all for VideoView for example.
P.S back then it seemed that I've managed to make the rotation thing work for anything other than VideoView though. Have you overriden the onTouchEvent method? If you have not your view won't be receiving the touch event since rotating the canvas will just make the view draw rotated but it will still receive the touch events in its old area. You have to manually apply rotation matrix to the touch event coordinates in order to offset them to the proper location.
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?