Android 全屏显示片段内定义的videoview
我有一个活动,它有两个框架布局,被两个片段替换。一个装有视频播放器(使用videoView),另一个装有视频列表。如下 video\u player\u activity.xmlAndroid 全屏显示片段内定义的videoview,android,android-fragments,android-framelayout,android-video-player,android-videoview,Android,Android Fragments,Android Framelayout,Android Video Player,Android Videoview,我有一个活动,它有两个框架布局,被两个片段替换。一个装有视频播放器(使用videoView),另一个装有视频列表。如下 video\u player\u activity.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
tools:context="com.example.project.android.VideoPlayerActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/rl_video_player_relativi_layout"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:id="@+id/fl_player_activity_video_surfrace_container"
>
</FrameLayout>
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rl_video_player_relativi_layout"
android:layout_marginTop="10dp"
android:id="@+id/fl_player_activity_video_list_container"
></FrameLayout>
我能够使用fragmentTransaction将这两个片段带到活动中。问题是当我尝试使用控件的全屏按钮全屏显示视频表面时,或者当它没有全屏显示时下面是我在VideoPlayerFragment.java中使用的代码使视图全屏显示
displayMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().
getMetrics(displayMetrics);
fullScreenWidth=displayMetrics.widthPixels;
fullScreenHeight=displayMetrics.heightPixels;
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.d("config changed to ","landscapte");
videoSurface.setDimensions(fullScreenHeight,fullScreenWidth);
isOrientationPortrat=false;
isFullScreen = true;
} else {
Log.d("config changed to ","portrait");
isOrientationPortrat=true;
}
}
有人能帮忙吗。。。!提前谢谢
displayMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().
getMetrics(displayMetrics);
fullScreenWidth=displayMetrics.widthPixels;
fullScreenHeight=displayMetrics.heightPixels;
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.d("config changed to ","landscapte");
videoSurface.setDimensions(fullScreenHeight,fullScreenWidth);
isOrientationPortrat=false;
isFullScreen = true;
} else {
Log.d("config changed to ","portrait");
isOrientationPortrat=true;
}
}