Created
April 1, 2021 06:46
-
-
Save Gkemon/db4c2a6b6ab8a230b8c46ce20218bec9 to your computer and use it in GitHub Desktop.
Rotate view by toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean isRotated= false; | |
View rotateLayout; | |
if(isRotated) | |
{ | |
rotateLayout.setRotation(360); | |
rotateLayout.setTranslationX(0); | |
rotateLayout.setTranslationY(0); | |
ViewGroup.LayoutParams lp = rotateLayout.getLayoutParams(); | |
lp.height = measuredHeight; | |
lp.width = measureWidth; | |
rotateLayout.requestLayout(); | |
mSignatureView.setTranslationX(linearLayout.getLeft()); | |
mSignatureView.setTranslationY(linearLayout.getTop()); | |
ViewGroup.LayoutParams lp1 = mSignatureView.getLayoutParams(); | |
lp1.height = measuredHeight; | |
lp1.width = measureWidth; | |
mSignatureView.requestLayout(); | |
isRotated=false; | |
} | |
else { | |
rotateLayout.setRotation(-90); | |
rotateLayout.setTranslationX((measureWidth - measuredHeight) / 2); | |
rotateLayout.setTranslationY((measuredHeight - measureWidth) / 2); | |
ViewGroup.LayoutParams lp = rotateLayout.getLayoutParams(); | |
lp.height = measureWidth; | |
lp.width = measuredHeight; | |
rotateLayout.requestLayout(); | |
mSignatureView.setTranslationX(linearLayout.getLeft()); | |
mSignatureView.setTranslationY(linearLayout.getTop()); | |
ViewGroup.LayoutParams lp2 = mSignatureView.getLayoutParams(); | |
lp2.height = measureWidth; | |
lp2.width = measuredHeight; | |
mSignatureView.requestLayout(); | |
isRotated=true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment