4

我有一個viewpager和一個導航抽屜。兩者都以橫向滑動方式進行操作,但是如何控制哪個人負責滑動操作?用viewpager和導航抽屜從左到右滑動

我viewpager:

Fragment[] allPictures = new Fragment[getNrPictures()]; 
APicturePageAdapter adapter = new APicturePageAdapter(super.getSupportFragmentManager(), allPictures); 
vP = (ViewPager) findViewById(R.id.picPage); 
vP.setAdapter(adapter); 

通過從螢幕上向右滑動到左,我可以通過圖片瀏覽。工作正常。 後來我加了導航抽屜:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:id="@+id/PicturePageContentLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginBottom="2dp" 
     android:orientation="vertical" > 

     ....... 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/left_drawer_ll" 
     android:layout_width="300dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="@android:color/white" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <TextView 
       ... content 
      </TextView> 

    </LinearLayout> 

打開和關閉抽屜工作正常,一切似乎是工作。但是,當我觸摸抽屜並向左滑動時,我希望抽屜自己關閉,而不是Viewpager翻轉到上一張圖片。我如何控制誰負責onTouch事件?

感謝您的任何幫助。

回答