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

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

问题描述

我正在 ImageView.ScaleType

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

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

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"

但用于VideoView.像这样的东西存在吗?

but for a VideoView. Does anything like this exist?

推荐答案

您只能使用TextureView实现此目的. (surfaceView也不起作用).这是一个在带有中心裁剪功能的TextureView中播放视频的库.不幸的是,TextureView只能在api级别14和更高版本中使用.

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天全站免登陆