Rotate screen when HTML5 video playing in fullscreen

折月煮酒 提交于 2019-12-05 22:51:09
Sebastian

I ended up in rotating the custom view container:

public class RotatedVerticalFrameLayout extends FrameLayout{

    public RotatedVerticalFrameLayout(Context context, AttributeSet attrs){
        super(context, attrs);
    }

    @SuppressWarnings("SuspiciousNameCombination")
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
        super.onMeasure(heightMeasureSpec, widthMeasureSpec);
        int w = getWidth();
        int h = getHeight();

        setRotation(90.0f);
        setTranslationX((h - w) / 2);
        setTranslationY((w - h) / 2);

        ViewGroup.LayoutParams lp = getLayoutParams();
        lp.height = w;
        lp.width = h;
        requestLayout();
    }
}

This looks like landscape mode if you only show the custom view instead of actionbar and other contents.

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