-1

This is my activity and it's working.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_playing);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    Intent intent = getIntent();
    String link = intent.getStringExtra("link");

    VideoView videoview = (VideoView) findViewById(R.id.videoView2);
    MediaController mediacontroller = new MediaController(this);
    mediacontroller.setAnchorView(videoview);
    Log.i("Link",link);
    Uri video = Uri.parse(link);
    videoview.setMediaController(mediacontroller);
    videoview.requestFocus();
    videoview.setVideoURI(video);
    videoview.start();
}

This is the screen when playing: enter image description here

But when the controller hides, the video screen is not fullscreen. enter image description here

How can Videoview display fullscreen when mediacontroller hides?

Pang
  • 9,564
  • 146
  • 81
  • 122

1 Answers1

0

I think you can create your myMediaController below to triger onHide of mediaController and refresh videoview

class myMediaController extends  MediaController{

    private View anchorView = null; //this ref to videoview from setAnchorView(View view)
    public myMediaController(Context context, boolean useFastForward) {
        super(context, useFastForward);
    }

    @Override
    public void setAnchorView(View view) {
        super.setAnchorView(view);

        anchorView = view;
    }

    @Override
    public void hide() {
        super.hide();
        anchorView.invalidate(); //refresh with and height of video view on screen
        anchorView.refreshDrawableState(); 
    }
}
GiapLee
  • 436
  • 2
  • 8