我有一个VideoView,这是设置为填充家长,并与全尺寸视频工作良好,我发现很难找到一个解决方案时,视频尺寸是4:3或更小,它保持在我的视图左侧,而同样的应用程序在ios显示它的全屏。我们可以调整视频的大小并以与视频视图相同的大小显示它吗?或者VideoView的内容可以调整大小吗?我试过了
view.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY);但是没有结果
发布于 2012-08-30 23:28:34
制作一个自定义视频类,如下所示:
public class CustomVideoView extends VideoView {
protected int _overrideWidth = 480;
protected int _overrideHeight = 360;
public CustomVideoView(Context context) {
super(context);
}
public CustomVideoView(Context context, AttributeSet set) {
super(context, set);
}
public void resizeVideo(int width, int height) {
_overrideHeight = height;
_overrideWidth = width;
// not sure whether it is useful or not but safe to do so
getHolder().setFixedSize(width, height);
//getHolder().setSizeFromLayout();
requestLayout();
invalidate(); // very important, so that onMeasure will be triggered
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
setMeasuredDimension(_overrideWidth, _overrideHeight);
}
}在您的类中,使用resizeVideo方法,并将屏幕宽度和高度作为参数。
考虑到这一切都取决于电影的比例和屏幕的比例。如果它们相同,则视频将全屏显示,但如果它们不同,则视频将调整为宽/高。
https://stackoverflow.com/questions/12200124
复制相似问题