I have a button that I want to put on a 45 degree angle. For some reason I can't get this to work.
Can someone please provide the code to accomplish this?
You can flip a layout by setting the View property scaleX to -1. So View#setScaleX(1f) is normal, and View#setScaleX(-1f) is flipped (visually). To do it pre-Honeycomb, you can use scale properties in the general Animation library.
1 Swipe down the screen to access your Quick Settings and tap on Auto Rotate, Portrait or Landscape to change your screen rotation settings. 2 By selecting Auto Rotate,you will easily be able to switch between Portrait and Landscape mode. 3 If you choose Portrait this will lock the screen from rotating to landscape.
API 11 added a setRotation() method to all views.
You could create an animation and apply it to your button view. For example:
// Locate view ImageView diskView = (ImageView) findViewById(R.id.imageView3); // Create an animation instance Animation an = new RotateAnimation(0.0f, 360.0f, pivotX, pivotY); // Set the animation's parameters an.setDuration(10000); // duration in ms an.setRepeatCount(0); // -1 = infinite repeated an.setRepeatMode(Animation.REVERSE); // reverses each repeat an.setFillAfter(true); // keep rotation after animation // Aply animation to image view diskView.setAnimation(an);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With