I need to use video as my background. First I placed the video file in drawable folder and called as background of LinearLayout in main.xml. But while running the app, I saw only a black screen. Then I tried to use VideoView and called it like following:
<VideoView
android:id="@+id/video"
android:layout_width="320px"
android:layout_height="240px"
android:layout_gravity="center"
android:background="@raw/hp"/>
In my activity file I called it with following code snippet:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView video=(VideoView) findViewById(R.id.video);
video.start();
}
But still I am not getting the video file there. My main propose is to use a bubble video as background and putting two bubble buttons on it and gives the user a feel like water view screen. Can anyone help me?
Also the video file I want to use from the res folder. Not from SD card or any outer media folder.
Well my friend, first of all you can’t set a background to your
VideoViewand make it play in the background of your screen.Please follow my steps and add your effort and you should be there.
Remove your video from drawable folder and add it to raw folder. Please google how to create a raw folder. It is simple though. And put your video file inside it.
First of all, create a
SurfaceViewin your xml like this.Now, create a class like the one below which can implement
SurfaceView,Now your class will ask for unimplemented methods to be added. Add those methods by just clicking on “Add unimplemented methods”
Now you will be able to see a auto generated method like this,
And inside this method,add the below code,