中心裁剪 Android VideoView [英] Center Crop an Android VideoView

查看:47
本文介绍了中心裁剪 Android VideoView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ImageView.ScaleType<块引用>

统一缩放图像(保持图像的纵横比),使图像的两个尺寸(宽度和高度)等于或大于视图的相应尺寸(减去填充).然后图像在视图中居中.在 XML 中,使用以下语法:android:scaleType="centerCrop"

但是对于 VideoView.有这样的东西吗?

解决方案

您只能使用 TextureView 来实现这一点.(surfaceView 也不起作用).这是一个用于在具有中心裁剪功能的纹理视图中播放视频的库.不幸的是,TextureView 只能在 api 级别 14 及更高版本中使用.

https://github.com/dmytrodanylyk/android-video-crop

另一种可能是将视频视图放大到恰到好处,但我还没有尝试过.

I am looking for something like the CENTER_CROP in ImageView.ScaleType

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding). The image is then centered in the view. From XML, use this syntax: android:scaleType="centerCrop"

but for a VideoView. Does anything like this exist?

解决方案

You can only achieve this with a TextureView. (surfaceView won't work either). Here's a lib for playing video in a textureView with center crop function. TextureView can only be used in api level 14 and up unfortunately.

https://github.com/dmytrodanylyk/android-video-crop

Another possibility is to zoom in the videoview just right, but I haven't tried that yet.

这篇关于中心裁剪 Android VideoView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆