0

I have a ImageView in NestedScrollView which I am hiding with animation using below method when I scroll up and the ImageView is not visible in the screen.

public static void collapse(final View v) {
        final int initialHeight = v.getMeasuredHeight();

        Animation a = new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                if (interpolatedTime == 1) {
                    v.setVisibility(View.GONE);
                } else {
                    v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                    v.requestLayout();
                }
            }

            @Override
            public boolean willChangeBounds() {
                return true;
            }
        };

        // 1dp/ms
        a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density) * 4);
        v.startAnimation(a);
    }

But as soon as the animation starts...it scrolls back to the ImageView then hides it. I don't want the ImageView to have focus at the time of animation. I am using animation because when I set the visiblity of ImageView to GONE, I see a flick or blink in my screen.

Kalpana
  • 23
  • 5
  • I'm not sure the View is actually getting "focus", as ImageViews should not be focusable in touch mode by default. And I couldn't find anything about Animations changing focus by default as well. Maybe you can debug the focus to see if this is actually you should be searching for, so you can go in the right track. – Vitor Hugo Schwaab Sep 18 '19 at 07:49
  • My NestedScrollView scrolls back to the ImageView when animation starts – Kalpana Sep 18 '19 at 08:56

0 Answers0