android - Video in landscape mode while press fullscreen Button -


i want continue video in landscape mode while press fullscreen button have used textureview , tried videoview , surfaceview

only view should landscape not whole activity screenorientation=landscape in manifest

this portrait mode

this portrait mode

what happening right now

what happening right now

this code

if (!isfullscreen()) {         isfullscreen=true;         sizeportait[0]=textureview.getwidth();         sizeportait[1]=textureview.getheight(); //          framelayout.layoutparams params = new framelayout.layoutparams(layoutparams.match_parent,layoutparams.match_parent);         framelayout.layoutparams params = new framelayout.layoutparams(mlayoutvideotrainig.getheight(),mlayoutvideotrainig.getwidth());         textureview.setrotation(90);         textureview.setlayoutparams(params);         adjustaspectratio(mlayoutvideotrainig.getheight(), mlayoutvideotrainig.getwidth());      }    /**  * sets textureview transform preserve aspect ratio of video.  */ private void adjustaspectratio(int videowidth, int videoheight) {     int viewwidth = videowidth;     int viewheight = videoheight;     double aspectratio = (double) videoheight / videowidth;      int newwidth, newheight;     if (viewheight > (int) (viewwidth * aspectratio)) {         // limited narrow width; restrict height         newwidth = viewwidth;         newheight = (int) (viewwidth * aspectratio);     } else {         // limited short height; restrict width         newwidth = (int) (viewheight / aspectratio);         newheight = viewheight;     }     int xoff = (viewwidth - newwidth) / 2;     int yoff = (viewheight - newheight) / 2;     log.v(tag, "video=" + videowidth + "x" + videoheight +             " view=" + viewwidth + "x" + viewheight +             " newview=" + newwidth + "x" + newheight +             " off=" + xoff + "," + yoff);      matrix txform = new matrix();     textureview.gettransform(txform);     txform.setscale((float) newwidth / viewwidth, (float) newheight / viewheight);     //txform.postrotate(10);          // fun     txform.posttranslate(xoff, yoff);     textureview.settransform(txform); } 

xml file

inside fragment

 <framelayout     android:id="@+id/videosurfacecontainer"     android:layout_width="match_parent"     android:layout_height="wrap_content" >      <textureview         android:id="@+id/videosurface"         android:layout_width="match_parent"         android:layout_height="200dp"          /> </framelayout>  <textview     android:id="@+id/txthowtoobtain"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:padding="8dp"     android:text="@string/how_to_obtain_the_best_mortgage_rate"     android:textcolor="@color/myaccentcolor"     android:textsize="22sp" /> 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -