Set a video as background

前端 未结 3 1000
孤独总比滥情好
孤独总比滥情好 2020-12-12 20:51

I am making a login screen for my Android app and was wondering how can I use a video as a background rather than having an image or simple colors?

I want to make it

3条回答
  •  有刺的猬
    2020-12-12 21:40

    NatureDevil answer and video is great but 2 things are missing first if you click on a button and open a new activity like sing-up and decided to click on back arrow on the device, the home screen will give black screen because the video will not restart so you need to add this

    @Override
    protected void onResume() {
        super.onResume();
        // to restart the video after coming from other activity like Sing up
        mVideoView.start();
    
    
    }
    

    other thing for the VideoView to stretch from left to right full screen add:

    android:layout_alignParentEnd="true"
    android:layout_alignParentStart="true"
    

提交回复
热议问题