I want to make android home page background. I have imported a video file hp.mkv into the drawable folder. And call the file in main.xml. Following is my code snippet:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/hp">
<Button android:id="@+id/next_button"
android:layout_width="200dp"
android:layout_height="200dp"
android:gravity="center"
android:layout_marginLeft="270dp"
android:layout_marginTop="180dp"
android:background="@drawable/button_background"/>
</RelativeLayout>
Again In main activity file called like this: setContentView(R.layout.main);
But while running the application I saw a black screen coming behind the button, where I was expecting the video file to come. Can any one suggest me how to get out from this problem. Or any idea of using video in app’s background in android.
Video files are not supported as “drawables”. In other words you can’t put it as drawable resource and expect it to be played back.
If you need video playback, you can use
MediaPlayer. But that would require some extra code to be added to your activity.