View pager onInterceptTouchEvent not generating event

浪子不回头ぞ 提交于 2019-12-12 03:23:00

问题


I have written an custom ViewPager but it's not generating event for Continuous Action.Move. On touch it generate DOWN once and MOVE event 2-3 time and that's it. Then after it not generate MOVE event.

Parent XML code.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <example.animation.com.CustomPager
        android:id="@+id/pager"
        android:background="#123456"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />



</FrameLayout>

Added Child Fragment XML implementation:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fmParent"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/txtIndex" />

</FrameLayout>

Any suggestion if I am missing anything here.


回答1:


Probably some view catch the event, so if just the ViewPager should catch the touches you can change the return of the ViewPagerfrom:

return super.onInterceptTouchEvent(ev);

to:

return true;


来源:https://stackoverflow.com/questions/28605921/view-pager-onintercepttouchevent-not-generating-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!