问题
Is there any way to rotate the screen? I mean, I would like to rotate my monitor 90º, I already tried to add the screen-rotation on the manifest, lcd_rotation and display_rotation both on boot/config.txt but without success.
Is that possible?
Thanks in advance!
回答1:
Try to change the orientation of your activity. In your manifest.xml, add the following line in the activity section:
android:screenOrientation="portrait"
回答2:
I was able to do a workaround for this issue while there's no beautiful way.
The idea was to rotate your activity layout.
public static void rotateScreen(final RelativeLayout layout, final Activity activity) {
Display display = activity.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int w = size.x;
int h = size.y;
layout.setRotation(90.0f);
layout.setTranslationX((w - h) / 2);
layout.setTranslationY((h - w) / 2);
ViewGroup.LayoutParams lp = layout.getLayoutParams();
lp.height = w;
lp.width = h;
layout.setLayoutParams(lp);
layout.requestLayout();
}
My main layout is a Relative, but you can generalize and do it for any one.
Thanks!
来源:https://stackoverflow.com/questions/46670917/how-to-rotate-hdmi-display-with-android-things