0

I have a CircledImageView which I'm using in my ViewPager. I want when I switch the tab on the ViewPager to animate the position of the CircledImageView to go to the bottom (currently is in the middle). Is this possible? My CircledImageView code:

<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" />
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
Radoslav Yordanov
  • 735
  • 1
  • 9
  • 20

1 Answers1

0

As user2286580 said. I had to create two methods and two listeners one for up direction and one for down direction:

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

And the listener:

    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) {
    }

}

For the up direction it's similar.

Radoslav Yordanov
  • 735
  • 1
  • 9
  • 20