move videoView…using translation animation

2019-02-17 19:21发布

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条回答
Fickle 薄情
2楼-- · 2019-02-17 19:59

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...

查看更多
登录 后发表回答