android - VideoView orientation change to full screen (show/hide actionbar and notification) -


hi have problem on playing orientation change. on portrait, have following xml in layout directory.

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent" >      <!-- player header -->     <linearlayout          android:id="@+id/player_header_bg"         android:layout_width="fill_parent"         android:layout_height="60dip"         android:background="@layout/bg_player_header"         android:layout_alignparenttop="true"         android:paddingleft="5dp"         android:paddingright="5dp">          <!-- song title -->         <textview              android:id="@+id/videotitle"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="1"             android:textcolor="#04b3d2"             android:textsize="16sp"             android:paddingleft="10dp"             android:textstyle="bold"             android:text="@string/song_def_title"             android:layout_margintop="10dp"/>          <!-- full screen button -->         <imagebutton              android:id="@+id/btnfullscreen"             android:layout_width="wrap_content"             android:layout_height="fill_parent"             android:src="@drawable/ic_action_refresh"             android:background="@null" />          <!-- playlist button -->         <imagebutton              android:id="@+id/btnplaylist"             android:layout_width="wrap_content"             android:layout_height="fill_parent"             android:src="@drawable/btn_playlist"             android:background="@null"/>     </linearlayout>      <videoview         android:id="@+id/surface_view"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         android:layout_alignparentleft="true"         android:layout_alignparentright="true"         android:layout_below="@+id/player_header_bg" >      </videoview>  </relativelayout> 

which when orientation change landscape, have xml in layout-land folder has same xml filename following 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"     android:orientation="vertical">      <videoview         android:id="@+id/surface_view"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:layout_alignparentbottom="true"         android:layout_alignparentleft="true"         android:layout_alignparentright="true"         android:layout_alignparenttop="true" >     </videoview>  </relativelayout> 

the orientation changes without issue, wanted ride of actionbar , notificationbar on landscape mode. , have come out on portrait mode.

i have tried manually override onconfigurationchanged method it's not working well.

@override     public void onconfigurationchanged(configuration newconfig) {         super.onconfigurationchanged(newconfig);          if (newconfig.orientation == configuration.orientation_landscape) {             actionbar actionbar = getactionbar();             actionbar.hide();              windowmanager.layoutparams attrs = getwindow().getattributes();              attrs.flags |= windowmanager.layoutparams.flag_fullscreen;              getwindow().setattributes(attrs);               // setcontentview(r.layout.player_video_fs);         } else if (newconfig.orientation == configuration.orientation_portrait) {             actionbar actionbar = getactionbar();             actionbar.show();              windowmanager.layoutparams attrs = getwindow().getattributes();              attrs.flags |= windowmanager.layoutparams.flag_force_not_fullscreen;              getwindow().setattributes(attrs);               // setcontentview(r.layout.player_video);         }     } 

if above, when changed landscape remove actionbar , notificationbar when change portrait, actionbar weird. see how cut off? actionbar

actiobar

and changing landscape, seem it's going blackscreen instead of continuing play video.

i have tried few other method still unable resolve. idea?

i having issue , stumbled upon question. know it's dated future developers come here.

after searching around found simple solution provided praveen instead of using compound or operator (|=) set window attribute flags can call getwindow().clearflags(flag) or getwindow().addflags(flag) functions

so revised version of hiding action bar when in landscape looks this:

if (newconfig.orientation == configuration.orientation_landscape) {     getactionbar().hide();     getwindow().addflags(windowmanager.layoutparams.flag_fullscreen); } else if (newconfig.orientation == configuration.orientation_portrait) {     getactionbar().show();     getwindow().clearflags(windowmanager.layoutparams.flag_fullscreen); } 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -