android - 居中裁剪 Android VideoView

标签 android scale center crop android-videoview

我正在寻找类似 ImageView.ScaleType 中的 CENTER_CROP 的东西

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。有这样的东西吗?

最佳答案

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

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

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

关于android - 居中裁剪 Android VideoView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19601921/

相关文章:

手机锁定时 Android 服务停止工作

CSS @keyframes 缩放文本模糊

html - 尝试通过 CSS 将图片居中放置在页面顶部

css - 居中对齐输入

scale - 如何使用 kubectl 命令关闭 Kubernetes 中的自动缩放?

asp.net - 试图让我的网页居中

java - 当我尝试将有效的代码带入类中时,它会出现错误

android - 编写自己的 Android 应用程序供个人使用?

android - 锁屏时获取Home键长按事件?

c++ - 如何在不缩放其内容的情况下调整 opengl 视口(viewport)大小