如何从屏幕的左下角到右上角以对角线方式移动VideoView

时间:2017-04-28 10:48:14

标签: android android-animation android-videoview

我希望在播放时不触摸(*无拖动,无用户参与)移动视频视​​图,移动应该在对角线路径中从屏幕的右上角到左下角。我尝试了不同的动画,但我无法实现这一点,试过以下代码。

mVideoView = (VideoView) findViewById(R.id.videoview2);

animateVideoView(mVideoView);

private void animateVideoView(View v){

DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

ObjectAnimator y = ObjectAnimator.ofFloat(v,
                "translationY", width, 100);

        ObjectAnimator x = ObjectAnimator.ofFloat(v,
                "translationX",100,height);

        animSetXY.playTogether(x, y);
        animSetXY.setInterpolator(new LinearInterpolator());
        animSetXY.setDuration(5000);
        animSetXY.start();
        v.startAnimation(animSetXY);



}

任何帮助将不胜感激......

1 个答案:

答案 0 :(得分:0)

看一下这个库,它可能有用https://github.com/pedrovgs/DraggablePanel