I solved a similar problem by hiding the media controller when the video view is not FULLY visible.
This is a custom media controller. It will check the visibility before showing.
package com.example.sixths.view;
import android.content.Context;
import android.widget.MediaController;
public class AutoMediaController extends MediaController {
public interface Checker {
boolean check();
}
public Checker checker;
public AutoMediaController(Context context) {
super(context);
}
public void setChecker(Checker checker) {
this.checker = checker;
}
@Override
public void show() {
if (!checker.check()) {
/* refuse to show if video_view is not fully visible */
return;
}
super.show();
}
}
check whether the video view is fully visible in your activity.
public class SomeActivity extends AppCompatActivity implements AutoMediaController.Checker {
/* .... */
public boolean check() {
Rect scrollBounds = new Rect();
scroll_view.getDrawingRect(scrollBounds);
float top = video_view.getY();
float bottom = top + video_view.getHeight();
/* if fully visible */
return scrollBounds.top <= top && scrollBounds.bottom >= bottom;
}
}
pass the checker to the controller.
AutoMediaController mediaController = new AutoMediaController(this);
mediaController.setChecker(this);
ref: Android: how to check if a View inside of ScrollView is visible?