如何在按钮单击时将视频旋转到横向模式?

时间:2016-07-14 15:05:44

标签: android android-videoview

我将视频放在VideoView和一个按钮中。我想要在单击按钮时,视频旋转到横向模式并适合设备的屏幕! 提前谢谢。

1 个答案:

答案 0 :(得分:0)

您只需设置屏幕方向即可。

Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new Button.OnClickListener(){
    @Override
    public void onClick(View arg0) {
           //This line will set the orientation to landscape. 
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

您只需要使用ACTIVITYINFO类中的值。

<强>资源

活动信息:https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_LANDSCAPE

风景:https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_LANDSCAPE

肖像:https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_PORTRAIT

相关问题