Android :: Rotate A Drawable Programmatically?
Sep 28, 2009
In my application I want to be able to rotate a view programmatically rather than via XML. I can easily create a <rotate/> drawable that references my Drawable, but I can not figure out how to do the same thing in Java. The problem is that many drawables in my scene can be displayed either vertically or horizontally and I do not want to have to create a separate rotate drawable for every drawable in my scene.
One thought I had was to instantiate a RotateDrawable in Java and then use that as the background for my view, but it does not appear that you can set the rotation of a RotateDrawable instantiated this way (you have to feed it XML to get it to be at all useful from what I can tell).
Another thought I had was to rotate the canvas, but I would like to be able to use the drawables as view backgrounds and I do not see a way to rotate the canvas before the background of a view is drawn and then revert it afterwards.
I also looked into creating some generic rotate drawable and then perhaps changing the drawable that it applies to, but that lead no where.
So, does anyone have any ideas about how I can rotate a drawable in code and then use that rotated drawable as a background?
View 6 Replies
Jun 8, 2010
I need to rotate an ImageView by a few degrees. I'm doing this by subclassing ImageView and overloading onDraw(). code...
The problem is that the image that results shows a bunch of jaggies.
How can I antialias an ImageView that I need to rotate in order to eliminate jaggies? Is there a better way to do this?
View 1 Replies
View Related
Sep 24, 2010
As we know, we can rotate a bitmap through 2 ways. The 1st way is: Matrix mt = new Matrix(); mt. postRotate (degree);Bitmap bitmap = CreateBitmap(src, 0, 0, w, h, mt, true); canvs.drawBitmap(bitmap, 0, 0, paint); In this way, we always need create new bitmap for every rotation, it is not good way for high performance game or app.The 2nd way is: canvas.save(); canvas.rotate(degree); canvas.drawBitmap(bitmap, 0, 0, paint); canvas.restore();In this way, we avoid creating new bitmap frequently, but the rotation bitmap is distortion, the bitmap quality is worse than first way.So, Is there 3rd way to rotate bitmap with high performance and good quality? Your any comments are really appreciated!
View 3 Replies
View Related
Oct 19, 2010
I am running my application in the emulator using a high density skin (like WVGA800). However the ressources in my application are loaded from the drawable- mdpi folder instead of drawable-hdpi ... what else should I do so that android use the correct folder ?
View 4 Replies
View Related
Jul 1, 2010
I just bought the Nexus One unlocked for AT&T and really like it. 1 wierd thing is that when I rotate the phone counter clockwise, the screen goes to landscape just fine; but when I rotate it clockwise it does not go to landscape "the other way". And, if I'm holding the phone 'normally' and rotate it 180 degrees ('upside down') it doesn't follow.My youngest daughter delights in telling me that her iPhone does this with no problem. What's up with that?
View 7 Replies
View Related
Oct 2, 2009
I have a HTC Magic (Rogers Canada).And, I see how the Dream (G1) rotates the home screen. can the Magic do that as well? Also, anybody know if it's possible to rotate the screen to the right and not just to the left? Shouldn't the acceleromater detect all the different rotated modes (even upside down?). that'd be cool
View 1 Replies
View Related
Oct 13, 2010
When the AVD screen is in an Eclipse frame there is a button on the frame to rotate orientation. How do I cause the same action when the AVD screen is floating outside Eclipse?
View 4 Replies
View Related
Feb 15, 2010
I am extending the normal android.widget.ProgressBar.This rotates it fine, however I am having alot of sizing issues. It seems as though I have to set the width and the height of the control to be the same thing or else I run into alot of clipping issues. Basically, I want to have a progress bar that, once rotated, is 50dip wide and fills the screen vertically. Can anyone think of a way to do this? Also, it doesn't seem to be actually drawing the progress properly, but I will revisit that once I get the clipping sorted out.
View 4 Replies
View Related
Apr 7, 2009
I need to rotate my view, say a button.I want the button to be 45 degrees rotated, and I want the button to also be functional.I want the touch area to remain only around the button.How can I rotate?
View 5 Replies
View Related
Feb 17, 2009
I want to rotate my view in specified degree, for example 30 degrees, 45 degrees.There is no rotate method in view class, I was trying to rotate its inside canvas, but the view doesn't rotate accordingly.
View 3 Replies
View Related
Jan 29, 2009
I'm fairly new to android development - I'm having trouble finding documentation on how to disable the accelerometer/auto-rotate feature for an app (i.e. when you turn the phone, everything 'corrects' changing the layout). Is it possible to disable in the emulator?
View 2 Replies
View Related
Nov 3, 2009
what i wont for example my g1 is Orentation enable and when my app start with screen rotate 90 then should be no rotating you know help me exam code pls.
View 2 Replies
View Related
Nov 15, 2010
does anyone know of an app that will turn the autorotate on / off from within an app on long search key press (or another key press)?I have searched the market / google and can't find anything..
View 6 Replies
View Related
Jun 28, 2010
Are there any 3rd party apps out there that rotate the screen 180 degrees? I can't seem to find any.Most times, I find it easier to use my Cliq if it is upside down (such as listening to music and charging.)
View 2 Replies
View Related
Feb 2, 2010
I am getting error when I rotate the device (it was HTC with Verizon):
The application My App (process com.mycompany.android) has
stopped unexpectadly. Please try again.
So, I think I need to code for this issue. In order words, when rotate the device from landscape to portable or from portable to landscape, application needs to catch this event.
Is it right ?
How to make it ? What is wrong here ?
Is it possible to test on the emulator ?
View 3 Replies
View Related
Jul 27, 2009
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...................
View 4 Replies
View Related
Dec 7, 2009
Is there any way to rotate gallery view vertically instead of horizontal.
View 3 Replies
View Related
Jun 27, 2009
I rotate image using setImageMatrix() function. I first use getImageMatrix() function to get matrix then i use matrix.postRotate (90). Rotation works fine. But it rotates around top/left corner of image. i want to change that pivot point to center of the image. how can I do that?
View 3 Replies
View Related
Feb 3, 2010
I have a layout with an image on it (embedded in an ImageView). I need to rotate the image (let's say) 90 degrees CCW. I've written code to animate the image rotating. The image smoothly rotates 90 degrees, but then snaps back to its original state. This is what the Android documentation says will happen after an animation completes. Presumably, on the notification that the animation has ended, I'm supposed to transform the ImageView (or the underlying drawable), and possibly invalidate it to trigger a redraw. All well and good, except that I can't find a way to do it, and I can't find any examples of anyone else doing it. I tried using getImageMatix/setImageMatrix on mImageView, with no apparent effect. There are subclasses of Drawable that will rotate an image, but there is no setDrawable() method on ImageView, so I don't see how to use one.
View 1 Replies
View Related
Oct 12, 2010
I know if you change a android phone from portrait to landscape sometimes the app relays its self out on the screen.. so how do I simulate rotating a phone with the AVD? On the Blackberry emulators there's a button in the menu to turn the phone, but I can't find it or any option on the Android ones?
View 1 Replies
View Related
Jul 14, 2009
In the api demo, there is an example for how to rotate a cube, but it can only rotate about X axis or Y axis, without Z-Axis Rotation. So how to perform 3D Rotation?
View 5 Replies
View Related
Sep 21, 2010
In android-sdk-windowsplatformsandroid-8data esdrawable progress_large.xml, the following code is used:
CODE:.........................
If I try to copy this code in my own projects (so I can change the drawable), I get a compile error for framesCount and frameDuration.
Is <animated-rotate> something that can be used? And if so, how?
View 3 Replies
View Related
Jan 1, 2010
I have a png-picture in ImageView rotatedimage = new ImageView ()
Is there a better way to rotate it in changing directions than the following way? There I have to create a new picture for every new rotating angle and add it to the layout...
View 2 Replies
View Related
Sep 19, 2010
I have a need to rotate the views in my activities by 180 degrees. Any good suggestions on how to do this? Taking into account touch inputs still working. My activity is made up of several views in a linearlayout and also makes use of toasts.
View 3 Replies
View Related
May 19, 2010
How to rotate same control in java? For example I want to rotate radiobutton for 90 or 180 degrees
How to do this on on JAVA SDK for android developing?
View 1 Replies
View Related
Nov 17, 2010
I have an app that snaps a picture and displays the picture on an Imageview. The problem is, I can only snap a pic in landscape mode in order for the bmp to be displayed right side up - Is there a way I can rotate it to right side up if the pic is taken in portrait mode.
View 1 Replies
View Related
Oct 10, 2010
I am trying to rotate a bitmap in OpenGL. I have searched around and come up with this. code...
Drawing the bitmaps indicated with the "ids" works fine but no rotation happens. I am no expert at openGL. Is is possible I need to set some sort of mode prior to the rotation?
View 8 Replies
View Related
Sep 19, 2010
Sometimes the screen auto-rotates when I don't want it to if I angle the phone slightly. I am constantly toggling it on and off. To do so of course, I have to go into settings, then display. Does anyone know of an app that I can add the toggle switch as a shortcut on my desktop? It is kind of a pain to go through the settings each and every time. I would much rather just hit it easily on my homescreen.
View 6 Replies
View Related
Oct 2, 2009
Not sure if this is the right section to ask but,is there a way to turn on auto rotate in google maps? As an example, if i lay down the phone and point it north, the map should point nort. But if i would to rotate the phone, the map should be facing the same direction.
View 2 Replies
View Related
Jul 28, 2010
I can't seem to rotate properly an image on the entire screen. The problem is that when the image rotates, you can see the background in some areas. I want the image to fill the screen also when it rotates. Here is the layout.I start the animation in onResume. As I said, the image rotates but there are background areas when it does rotate. I've tried using images much bigger than the screen but still it doesn't do what I want. I don't care that outer regions of the image are not visible. I just want the rotation to fill the screen. I guess ImageView sets its width and height initially and then, when it rotates, it uses those dimensions. Is there a better way to do this?
View 2 Replies
View Related