fullscreen - Android VideoView orientation like Youtube app -
i'm trying replicate in app youtube app when playing video.
portrait mode: shows video using 40% of screen , rest information video.
landscape mode: shows video , window in fullscreen mode.
i've seen lot of threads in stack overflow , other forums subject, none of them seem work me. have videoplayeractivity android:configchanges="keyboardhidden|orientation|screensize" , i've overriden onconfigurationchanged event following code:
@override public void onconfigurationchanged(configuration config) { super.onconfigurationchanged(config); if (config.orientation == configuration.orientation_landscape) { // requestwindowfeature(window.feature_no_title); getwindow().clearflags(windowmanager.layoutparams.flag_force_not_fullscreen); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); } else { getwindow().clearflags(windowmanager.layoutparams.flag_fullscreen); getwindow().setflags(windowmanager.layoutparams.flag_force_not_fullscreen, windowmanager.layoutparams.flag_force_not_fullscreen); } }
this doesn't put app in fullscreen, , if uncomment requestwindowfeature crash because "requestfeature() must called before adding content". later on i've tried removing onconfigurationchanged event , on oncreate event i've tried :
@override public void oncreate(bundle savedinstancestate) { if (getresources().getconfiguration().orientation == configuration.orientation_landscape) { requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); } super.oncreate(savedinstancestate); setcontentview(r.layout.activity_video);
but crashes nullpointerexception @ com.android.internal.policy.impl.phonewindow$panelfeaturestate.onrestoreinstancestate(phonewindow.java:3527) if start activity on portrait , flip landscape. suggestions?
to put in fullscreen:
video_layout.xml:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <videoview android:id="@+id/video" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparentright="true" android:layout_alignparenttop="true" />
activity:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); } @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); }
and support orientation changes youtube app: toggling fullscreen & orientation youtube
Comments
Post a Comment