It's actually really easy, and you don't need to use animations. I
did something like this recently by using a wrapper layout that
adjusts the Canvas and any MotionEvents. (You could also use this
approach rotate the entire layout to any arbitrary angle.)
I think romainguy told me to use Canvas.concat(mForward) instead of
setMatrix(), but I haven't updated the code in awhile.
private static class FlipLayout extends FrameLayout {
private Matrix mForward = new Matrix();
private Matrix mReverse = new Matrix();
private float[] mTemp = new float[2];
public FlipLayout(Context context) {
super(context);
mForward.postRotate(180);
mForward.invert(mReverse);
}
@Override
protected void dispatchDraw(Canvas canvas) {
canvas.setMatrix(mForward);
super.dispatchDraw(canvas);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
final float[] temp = mTemp;
temp[0] = event.getX();
temp[1] = event.getY();
mReverse.mapPoints(temp);
event.setLocation(temp[0], temp[1]);
return super.dispatchTouchEvent(event);
}
}
On Fri, Jul 24, 2009 at 10:53 PM, Josh Hoffman<[email protected]> wrote:
>
> I posted earlier today on this topic, but I'm re-posting as I haven't
> been able to locate my post via search. I apologize if this is indeed
> a double-post, but it seems something went wrong with the original.
>
> I've been trying to find a means of rotating a view such that it is
> flipped upside-down and stays that way. I found the Rotation Animation
> method, but I have been unable to find a means of keeping the view
> rotated. Repeating the animation doesn't suit my purposes, and in fact
> I don't want an animation at all if possible. What I would like is
> something akin to a transformation, except to be used on a TextView or
> a LinearLayout.
>
> I have considering overriding methods to accomplish this task by
> slightly modifying the animation code, but I'm not sure how extensive
> the work for this would be. Additionally, I'm not sure where to find
> the source for those methods.
>
> If anyone could recommend a means of accomplishing this task, whether
> it be by an override or perhaps something simple that I am missing, I
> would appreciate it very much. Thanks!
>
> >
>
--
Jeff Sharkey
[email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---