Q:

How is it possible to viewpager swiping being enable while an overlay is shown

I have this xml layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/root_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    >

    <com.duolingo.open.rtlviewpager.RtlViewPager
        android:id="@+id/book_reader_viewpager_portrait"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@color/white"
        tools:visibility="visible"
        android:visibility="gone" />

    <ImageView
        android:id="@+id/icon_pause"
        android:layout_width="@dimen/book_reader_pause"
        android:layout_height="@dimen/book_reader_pause"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="16dp"
        android:src="@drawable/icon_pause" />

    <include layout="@layout/loading_screen" />

    <include layout="@layout/layout_offline_no_data" />

    <include layout="@layout/layout_error_no_data" />

    <include layout="@layout/layout_book_reader_overlay" />

    <include layout="@layout/layout_book_reader_continue_or_startover" />

</RelativeLayout>

I have this issue that when this overlay is shown (layout_book_reader_overlay) I can swipe or scroll page horizontally .. which shouldn't be happening as I understand

A:

Touch and click events are passed to the highest View that accepts them. If you do not want the ViewPager to swipe when the overlay is shown, set android:clickable="true" on the root View of the overlay layout. That way, it will take click events away from the ViewPager, even if it does not respond to them.
Note that for this to really work, your overlay must fully cover the ViewPager, otherwise the parts that are not covered will still be swipeable. If the overlay is not meant to be full-screen, then you can make the outermost View of the overlay full-screen and transparent, make that clickable, then put the actual overlay inside it.
<FrameLayout
    xmlns:android="..."
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true">
    <!-- put your overlay layout in here -->
</FrameLayout>

