Sun*_*nny 1 video android surfaceview
我正在使用surfaceview播放本地mp4视频,这里是布局
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<SurfaceView
android:id="@+id/surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</SurfaceView>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
从代码我将全屏设置为surfaceview
int height = getWindowManager().getDefaultDisplay().getHeight(); //metrics.heightPixels;
int width = getWindowManager().getDefaultDisplay().getHeight(); //metrics.widthPixels;
mPreview = (SurfaceView) findViewById(R.id.surface);
LayoutParams lp = new FrameLayout.LayoutParams(width, height);
mPreview.setLayoutParams(lp);
holder = mPreview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//holder.setFixedSize(width, height);
holder.setSizeFromLayout();
Run Code Online (Sandbox Code Playgroud)
但是,现在问题是视频没有全屏播放,视频上方有黑屏.
截图http://i.imgur.com/WNFDM.png 如何播放全屏视频?
小智 5
不知道这有多久了.试试这个
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
在对活动的onCreate方法执行setContentView之前
| 归档时间: |
|
| 查看次数: |
8905 次 |
| 最近记录: |