Goal:
Get the width, height, and margins from a rotated view.
I'm rotating the view with: view.animate().rotationBy(90);
I've also tried doing it with a RotateAnimation to no avail.
Details:
I'm moving a non-square view around the screen, with the ability to rotate it, and I want to keep the view within the bounds of the screen - e.g. no part of the view leaves the screen. Or at least if it does, it moves back in bounds.
When the view isn't rotated, everything works fine when I use LayoutParams and prevent its top and left margins from being negative (or greater than the height/width of the screen, respectively). I'm running into problems when the view is rotated because when I use the LayoutParams, they're retaining their values from the non-rotated View.
Example:
See screenshot of Excel-built example. If my original view's top-left corner is one cell each from the top and left (1,1), when rotated 90 degrees, I'd expect the new top-left corner to be two cells from the top, and zero cells from the left (2,0). However, the top-left corner (as far as the LayoutParams are concerned), remains at 1,1.
Within the same example, the height and width do not change in the LayoutParams. Whether or not it's rotated, the height is always four cells and the width is always two.