我有一个带有视频的片段,我不想将片段更改为fragmentActivity,但是,我不知道如何删除片段的状态栏,任何人都可以帮助):
public class VideoFragment1 extends Fragment {
public VideoFragment1() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getActivity().getActionBar().hide();
View rootView = inflater.inflate(R.layout.fragment_video1, container, false);
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
return rootView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
Activity v = getActivity();
final VideoView videoView =
(VideoView)v.findViewById(R.id.youtubeplayerview);
videoView.setVideoPath(
"");
MediaController mediaController = new MediaController(v.getApplicationContext());
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.start();
}
}
答案 0 :(得分:2)
在片段的活动中使用它。
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
答案 1 :(得分:0)
您可以使用以下代码全屏显示您的Videoview。 mVideoViewRelativeLayout是您的Videoview插入其中的Relativelayout。希望它能工作。另外,如果还有多余的内容,则必须隐藏可见性。
ACTIVITY_IN_PORTRAIT = false;
ACTIVITY_IN_LANDSCAPE = true;
mFullScreen.setImageResource(R.drawable.minimize);
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
Timber.e("onconfigurationchanged landscape" + metrics.widthPixels + metrics.heightPixels);
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, metrics.heightPixels);
rel_btn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
rel_btn.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
rel_btn.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rel_btn.addRule(RelativeLayout.ALIGN_PARENT_TOP);
rel_btn.setMargins(0, 0, 0, 0);
mVideoViewRelativeLayout.setLayoutParams(rel_btn);
playerView.setLayoutParams(rel_btn);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
View v = getActivity().getWindow().getDecorView();
v.setSystemUiVisibility(GONE);
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
getActivity().getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}