Android中的TranslateAnimation与相邻视图

时间:2015-10-24 04:59:23

标签: android android-layout android-animation

我有TransaleAnimation的视图非常好。问题是视图有一个android:layout_toRightOf =" @ id / iv_hook"到一个没有视图动画的ImageView。有没有办法实现这个目标?

1 个答案:

答案 0 :(得分:0)

  

ImageView用于显示/隐藏。当视图滑出时,我想要显示“显示”图像。

尝试这样的事情:

// yourImageView is hidden => its visibility is View.GONE


// animate your view with translation => slide out effect
viewToAnimate.animate().translationX(newTranslationX).setDuration(duration).withEndAction(new Runnable() {
    @Override
    public void run() {
        // now, as the animation has just finished, we want to show the image
        yourImageView.setVisibility(View.VISIBLE);
    }
}).start();