2015-09-12 50 views
0

在相对布局中有一个viewpager和RelativeLayout。ViewPager在其上有视图时无法响应触摸事件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:weather="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/mainview_id"> 

<android.support.v4.view.ViewPager 
    android:id="@+id/main_viewpager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 
<PushPullDoorView 
    android:id="@+id/pull_down_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
</PushPullDoorView> 

的PushPullDoorView已经覆盖的onTouchEvent method.it可以被拖累而up.But当我尝试移动viewpager,它不会响应event.I尝试覆盖dispatchTouchEvent ,onInterceptTouchEvent,并设置返回值为true或false.It仍然不起作用。

回答

0

PushPullDoorView和android.support.v4.view.ViewPager都有android:layout_height =“match_parent”,所以只有一个视图会在屏幕上联系。尝试改变布局设计来解决这个问题。

+0

PushPullDoorView具有透明背景。我们可以看到视图内容。所以我想在被覆盖的时候移动vewpager。任何想法? – shaotine

+0

我发现了我在onTouchEvent方法中返回true的原因。删除它,它完美地工作。 – shaotine

相关问题