对于一个项目,我必须对视频逐帧进行一些操作(就像在视频上绘制元素一样)。有没有方法可以让我在Android上一帧一帧地进行操作?
发布于 2016-07-01 19:04:15
如果你有帧,你可以使用Android的逐帧动画技术。
在可绘制文件夹中创建一个新文件,即frames.xml
<!-- Animation frames are wheel0.png through wheel5.png files inside the res/drawable/ folder --> <animation-list android:id="@+id/selected" android:oneshot="false"> <item android:drawable="@drawable/wheel0" android:duration="50" /> <item android:drawable="@drawable/wheel1" android:duration="50" /> <item android:drawable="@drawable/wheel2" android:duration="50" /> <item android:drawable="@drawable/wheel3" android:duration="50" /> <item android:drawable="@drawable/wheel4" android:duration="50" /> <item android:drawable="@drawable/wheel5" android:duration="50" /> </animation-list>
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);img.setBackgroundResource(R.drawable.spin_animation);AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
//启动动画(默认循环播放)frameAnimation.start();
参考。
https://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html
https://stackoverflow.com/questions/38143484
复制相似问题