0

I am using TextureView in Fragment and I am playing video in TextureView. I have a button in Fragment and want to play video in full screen the button is clicked. It is possible in Fragment because I am using Fragment in an Activity.

How can I achieve this?

David Guyon
  • 2,759
  • 1
  • 28
  • 40
rohit sharma
  • 27
  • 10

1 Answers1

0

In your activity, before setContentView()

requestWindowFeature(Window.FEATURE_NO_TITLE);
//Now you have a full screen view of an activity

if you are changing orientation of your phone from Portrait to Landscape, then add android:configChanges="orientation|screenSize" in Activity tag Manifest.xml, then in code do the following

private int oldOptions;

@Override
public void onConfigurationChanged(Configuration newConfig)
{
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
    {
        oldOptions = getWindow().getDecorView().getSystemUiVisibility();
        int newOptions = oldOptions;
        newOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
        newOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
        newOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        newOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
        newOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        getWindow().getDecorView().setSystemUiVisibility(newOptions);
        getActionBar().hide();
    }
    else
    {
        getWindow().getDecorView().setSystemUiVisibility(oldOptions);
        getActionBar().show();
    }
}
Stefan
  • 5,203
  • 8
  • 27
  • 51
Murtaza Khursheed Hussain
  • 15,176
  • 7
  • 58
  • 83