2015-09-12 86 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

相關問題