没有4.2的机子,帮帮忙,谢谢看看视频是否全屏的代码如下package com.example.testvideoview;import java.io.File;import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;public class MainActivity extends Activity { private VideoView videoView1;
private MediaController mediaController; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); getViews();
ViewTreeObserver vto = videoView1.getViewTreeObserver(); 
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { 
    public boolean onPreDraw() { 
        int height = videoView1.getMeasuredHeight(); 
        int width = videoView1.getMeasuredWidth(); 
        Toast.makeText(MainActivity.this, "w = " + width + " h = " + height,
Toast.LENGTH_SHORT).show();
        return true; 
    } 
});
mediaController = new MediaController(this);
// String videoPath = "/sdcard/MSDgames/videos/v2_bak.mp4";
 String videoPath = "/sdcard1/video/S01-01.mpg";
File videoFile = new File(videoPath); if (videoFile.exists() && videoFile.isFile()) {
videoView1.setVideoPath(videoFile.getAbsolutePath());
videoView1.setMediaController(mediaController);
mediaController.setMediaPlayer(videoView1);
videoView1.requestFocus();
videoView1.start();// int w = View.MeasureSpec.makeMeasureSpec(0,
// View.MeasureSpec.UNSPECIFIED);
// int h = View.MeasureSpec.makeMeasureSpec(0,
// View.MeasureSpec.UNSPECIFIED);
// videoView1.measure(w, h);
// int height = videoView1.getMeasuredHeight();
// int width = videoView1.getMeasuredWidth();
//
// int height = videoView1.getHeight();
// int width = videoView1.getWidth();// Toast.makeText(this, "w = " + width + " h = " + height,
// Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "no video", Toast.LENGTH_SHORT).show();
} } /**
 * 
 */
private void getViews() {
videoView1 = (VideoView) findViewById(R.id.videoView1);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}}/**
 * 
 */
package com.example.testvideoview.ui;import android.content.Context;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.widget.VideoView;/**
 * @author admin
 *
 */
public class MyVideoView extends VideoView { public MyVideoView(Context context) {
super(context);
}

public MyVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
    }    public MyVideoView(Context context, AttributeSet attrs, int defStyle) {
     super(context, attrs, defStyle);
    }    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
     DisplayMetrics dm = getResources().getDisplayMetrics(); int screenWidth = dm.widthPixels;
int screenHeight = dm.heightPixels;
setMeasuredDimension(screenWidth, screenHeight);
    }
}<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >    <com.example.testvideoview.ui.MyVideoView
        android:id="@+id/videoView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" /></RelativeLayout>

解决方案 »

  1.   

    忘了说了,需要修改视频地址
    在android4.1中是可以全屏的
      

  2.   

    还有一个文件
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.testvideoview"
        android:versionCode="1"
        android:versionName="1.0" >    <uses-sdk
            android:minSdkVersion="15"
            android:targetSdkVersion="17" />    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.testvideoview.MainActivity"
                android:label="@string/app_name"
                android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application></manifest>
      

  3.   

    AVD.
      

  4.   

    搞笑的求助搞笑的回答哈哈,模拟器而已啊,你更新4.2的sdk而后启动4.2的模拟器不就可以自己测了嘛......