Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7057339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:58:27+00:00 2026-05-28T03:58:27+00:00

I need to use video as my background. First I placed the video file

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:58:28+00:00Added an answer on May 28, 2026 at 3:58 am

    Well my friend, first of all you can’t set a background to your VideoView and 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 SurfaceView in your xml like this.

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
                android:id="@+id/home_container"  
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent">
    
    <SurfaceView 
            android:id="@+id/surface" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:paddingTop="10dip" />
    </Framelayout>
    

    Now, create a class like the one below which can implement SurfaceView,

    public class YourMovieActivity extends Activity implements SurfaceHolder.Callback {
        private MediaPlayer mp = null;
        //...
      SurfaceView mSurfaceView=null;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            mp = new MediaPlayer();
            mSurfaceView = (SurfaceView) findViewById(R.id.surface);
            mSurfaceView.getHolder().addCallback(this);
            //...
        }
    }
    

    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,

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
    
    }
    

    And inside this method,add the below code,

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
    
    
       Uri video = Uri.parse("android.resource://" + getPackageName() + "/" 
          + R.raw.your_raw_file);
    
        mp.setDataSource(video);
        mp.prepare();
    
        //Get the dimensions of the video
        int videoWidth = mp.getVideoWidth();
        int videoHeight = mp.getVideoHeight();
    
        //Get the width of the screen
        int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
    
        //Get the SurfaceView layout parameters
        android.view.ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();
    
        //Set the width of the SurfaceView to the width of the screen
        lp.width = screenWidth;
    
        //Set the height of the SurfaceView to match the aspect ratio of the video 
        //be sure to cast these as floats otherwise the calculation will likely be 0
        lp.height = (int) (((float)videoHeight / (float)videoWidth) * (float)screenWidth);
    
        //Commit the layout parameters
        mSurfaceView.setLayoutParams(lp);        
    
        //Start video
        mp.setDisplay(holder);
        mp.start();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i make iPhone web which need to play video.i use video tag for video
I need to use a C library to access and older file format used
I am in need to use This Class to server multiple files (img/video/mp3) from
So, I need use this event so I can navigate trought blog posts. I
Need to use own imaged markers instead built-in pins. I have several questions. 1.
I need to use the $.ajax() call within jQuery to post a little bit
I need to use this formula to calculate the upper limit and lower limit
I need to use a forward chainer in certain Prolog problem. I would like
I need to use cv::FindContours() in a program and I have to know the
I need to use recursion to for a method I'm trying to implement. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.