Java tutorial
//package com.java2s; import android.support.annotation.NonNull; import android.view.View; public class Main { public static void rotateView(@NonNull View rotatedView) { int w = rotatedView.getWidth(), h = rotatedView.getHeight(); int diff = w / 2 - h / 2; rotatedView.setRotation(270); rotatedView.setTranslationX(-diff); } }