android使用videoview 全屏方法

今天使用videoview 播放MP4文件时,无法全屏播放,于是找了好多的方法都没有办法全屏。下面是我自己写的继承videoview 的类,


package com.nwsuaf.fairgroundsnavigation.ui;


import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;


public class FullScreenVideoView extends VideoView{


public FullScreenVideoView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public FullScreenVideoView (Context context, AttributeSet attrs)
{
super(context,attrs);
}
public FullScreenVideoView(Context context, AttributeSet attrs,int defStyle)
{
super(context,attrs,defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
  int width = getDefaultSize(0, widthMeasureSpec);
  int height = getDefaultSize(0, heightMeasureSpec);
  setMeasuredDimension(width , height);
}


}




然后再xml使用这个自定义的fullscreenvideoview就可以啦,
布局文件也贴出来吧!


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <com.nwsuaf.fairgroundsnavigation.ui.FullScreenVideoView
     android:id="@+id/videoView"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:layout_gravity="center"
    />
</LinearLayout>




希望对大家有用!
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值