I’m following a tutorial and try to build a custom video player, over the Android’s VideoView.
Now, when I touch the VideoView I want to show or hide the media controllers. If controllers are already shown, then hide them, if they are hidden, then show them.
Those media controllers are represented by 2 LinearLayouts, that sits over the VideoView.
The area highlighted with red, represents the VideoView borders in background.
My problem is that when I touch an area of media controller where it overlaps the VideoView, the media controllers are hidden. This is not the desired effect, because I’m not touching directly the VideoView, but the LinearLayout.
So, why the Videoview catches the touch events when I’m clicking on LinearLayouts?

Here’s my onTouch implementation:
@Override
public boolean onTouch(View v, MotionEvent event) {
if (!isMediaControlerShown) {
topPanel.setVisibility(View.VISIBLE);
bottomPanel.setVisibility(View.VISIBLE);
isMediaControlerShown = true;
} else {
topPanel.setVisibility(View.GONE);
bottomPanel.setVisibility(View.GONE);
isMediaControlerShown = false;
}
return false;
}
And the scheleton of XML layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<VideoView
android:id="@+id/videoView"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:layout_height="wrap_content" />
<!-- The top panel of the Video Player -->
<LinearLayout
android:visibility="gone"
android:id="@+id/top_panel"
style="@style/VideoTopPanel"
android:orientation="vertical" >
<!-- ////// -->
</LinearLayout>
<!-- The bottom panel of the Video Player -->
<LinearLayout
android:visibility="gone"
android:id="@+id/bottom_panel"
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/VideoBottomPanel"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:paddingBottom="@dimen/video_bottom_panel_padding_bottom"
android:paddingTop="@dimen/video_bottom_panel_padding_top" >
<!-- ////// -->
</LinearLayout>
</RelativeLayout>
The issue was solved by setting a click listener to the view that was holding the controls, but do nothing onClick()
This way, the view received the click events and didn’t disappear.