soodabeh
soodabeh

Reputation: 23

rotate a layout without using animation

I'm trying to rotate hole layout by this code:

RelativeLayout rll = (RelativeLayout) findViewById(R.id.relativeLayout1);
rll.setRotation(21);

how can I set rotation center?I don't want to use left bottom corner as rotation center,because some parts of rotated layout is out of the view!! (I don't want to use animation. bcz my buttons don't work correctly with it)

Upvotes: 1

Views: 527

Answers (2)

erik
erik

Reputation: 4958

Not sure i understand what you are asking but try this:

 int w = r11.getWidth();
 int h = r11.getHeight();

 r11.setRotation(21f);
 r11.setTranslationX((w - h) / 2);
 r11.setTranslationY((h - w) / 2);

Upvotes: 0

Related Questions