2015-12-21 50 views
-1

這是我的活動,它的工作。當mediacontroller隱藏時,Videoview如何顯示全屏?

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(); 
} 

這是播放時屏幕: enter image description here

但是當控制器皮,視頻畫面是不是全屏。 enter image description here

mediacontroller隱藏時,Videoview如何顯示全屏?

回答

0

我覺得你可以到下面的的MediaController TRIGER onHide創建您的myMediaController並刷新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(); 
    } 
} 
相關問題