Animate CircledImageView位置

时间:2015-04-09 07:11:45

标签: android

我有CircledImageView我在ViewPager中使用了ViewPager。我希望当我切换CircledImageView上的标签时,为<android.support.wearable.view.CircledImageView android:id="@+id/moreIcon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_below="@+id/backDropPath" android:layout_gravity="right" android:layout_marginRight="15dp" android:layout_marginTop="-28dp" android:adjustViewBounds="false" android:src="@drawable/ic_more_vert_white_36dp" app:circle_color="@color/detailsMoreIconBackground" app:circle_radius="28dp" /> 的位置设置动画以显示底部(当前位于中间)。这可能吗? 我的CircledImageView代码:

{{1}}

1 个答案:

答案 0 :(得分:0)

正如用户2286580所说。我必须创建两个方法和两个侦听器,一个用于向上方向,一个用于向下方向:

    public void createDownAnimation() {
    downAnimation = new TranslateAnimation(0, 50, 0, 100);
    downAnimation.setDuration(500);
    downAnimation.setFillAfter(false);
    downAnimation.setAnimationListener(new DownAnimationListener());
}

听众:

    private class DownAnimationListener implements Animation.AnimationListener {

    @Override
    public void onAnimationEnd(Animation animation) {
        moreIcon.clearAnimation();
        LayoutParams lp = new LayoutParams(imageView.getWidth(), imageView.getHeight());
        lp.setMargins(50, 100, 0, 0);
        moreIcon.setLayoutParams(lp);
        moreIcon.setVisibility(View.VISIBLE);
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
    }

    @Override
    public void onAnimationStart(Animation animation) {
    }

}

对于向上的方向,它是相似的。

相关问题