How to rotate HDMI display with Android Things

谁都会走 提交于 2019-12-11 16:05:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!