0
votes

I have a scrollview in my content page with my custom view and Gridview, as shown below.

<ScrollView Orientation="Vertical">
//Custom content view
//Gridview
</ScrollView>

Dynamically i am hiding and showing my custom content view by using IsVisibile property. When my custom view is hided, the grid view automatically adjusts it position without animation. Is there any way to animate the transition.

1

1 Answers

0
votes

Override your custom view's setVisibility() function to run animation before it 'actually' be hidden.


Something like below:
(This code is just an example, it will only works with View.GONE by itself!)

// assume your view will be shredded by Y-axis

@Override
public void setVisibility(final int visibility) {
    if(isAnimating)
    {
        return;
    }

    isAnimating = true;

    animate().scaleY(0).setDuration(700).setInterpolator(AnimationUtil.DECEL)
            .withEndAction(new Runnable() {
                @Override
                public void run() {
                    isAnimating = false;
                    setActualVisibility(visibility);
                }
            });
}
private void setActualVisibility(int visibility)
{
    super.setVisibility(visibility);
}