move videoView…using translation animation

陌路散爱 提交于 2019-12-19 08:12:46

问题


I am basically trying to move the VideoView I have by using an animator on the layout that contains in. However, the video view never moves. Its layout moves, but not the video itself?

How can I make the video move?

here is what i have so far.

the slideleft.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0%" android:toXDelta="-50%" android:duration="200"
    android:fillAfter ="true" android:fillEnabled="true"
android:interpolator="@android:anim/accelerate_decelerate_interpolator" />
</set>

the animation portion in activiy (reinitialized animators everytime just to make sure)

public void videoSlideOut(long time){
    rn2 = new Runnable(){
        public void run() {
            Animation SlideLeft = AnimationUtils.loadAnimation(Video.this, R.anim.slideleft);
            Animation SlideLeft2 = AnimationUtils.loadAnimation(Video.this, R.anim.slideleft);
            ((RelativeLayout) findViewById(R.id.video_view_slider)).startAnimation(SlideLeft);
            video.startAnimation(SlideLeft2);
        }
    };
    hnd.postDelayed(rn2, time);

}

回答1:


I don't think you can animate VideoView like this. Basicly animation takes drawing cache/layer of the window and then animates it. But VideoView uses SurfaceView for rendering video. And, as far as I know, SurfaceView can't be animated with Animation class.

You can try Animator but I'm not sure if it'll work...



来源:https://stackoverflow.com/questions/8719028/move-videoview-using-translation-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!