11

I have a media controller in my android activity which uses setAnchorView to set the initial position. From what I have read if the media controller is in a scrollview the window of the media controller simply follows the scrolling which is obviously not what I want.

Is there some method to programatically fix the position of the media controller so it does not follow the scrollview?

Many thanks.

David
  • 111
  • 4

2 Answers2

14

You can hide media control on scroll event. It's not fix problem with view position but at least it's not visible.

scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {

            @Override
            public void onScrollChanged() {
                mediaController.hide();
            }
        });
0
Mediacontroller mediaController = findviewby(R.id."Your mediaController Id");
Scrollview scrollView = findviewby(R.id."Your Scrollview Id");
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {

            @Override
            public void onScrollChanged() {
                mediaController.hide();
            }
        });
vimuth
  • 5,064
  • 33
  • 79
  • 116