No I need to return false, so that the parent view's onTouch event gets called. If I return true, then the event ends there and does not get passed up the view hierarchy.
Here is my main activity's layout:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FfFfFf" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" />
<ProgressBar
android:id="@+id/progress_indicator"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:visibility="invisible" />
<RelativeLayout
android:id="@+id/drawhouse"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_gravity="start"
android:background="#ffffff"
android:orientation="vertical" >
<ListView
android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/buttonrow"
android:choiceMode="singleChoice"
android:divider="#808080"
android:dividerHeight="1dp" />
<TextView
android:id="@+id/empty_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingTop="2dp"
android:text="@string/emptyDrawer"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
<RelativeLayout
android:id="@+id/buttonrow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#E6E6E6" >
<Button
android:id="@+id/refresh"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:background="@drawable/ic_menu_refresh" >
</Button>
<Button
android:id="@+id/search"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:background="@drawable/ic_btn_search" >
</Button>
<Button
android:id="@+id/downloadFilter"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:layout_toLeftOf="@+id/search"
android:background="@drawable/download" >
</Button>
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
Now I want the actionbar to disappear when the user touches (but does not swipe) the screen. I have this code in my main activity's onCreate event:
mDrawerLayout = (DrawerLayout) findViewById(R.id.activity_main);
mDrawerLayout.setOnTouchListener(new OnSwipeTouchListener(this)
{
boolean isSwipe = false;
public void onSwipeRight() {
isSwipe = true;
}
public void onSwipeLeft() {
isSwipe = true;
}
public void onSwipeTop() {
isSwipe = true;
}
public void onSwipeBottom() {
isSwipe = true;
}
@Override
public boolean onTouch(View v, MotionEvent event)
{
super.onTouch(v, event);
int eventaction = event.getAction();
switch (eventaction)
{
case MotionEvent.ACTION_UP:
if(!isSwipe)
{
if (isActionBarShown)
{
getActionBar().hide();
isActionBarShown = false;
}
else
{
getActionBar().show();
isActionBarShown = true;
}
}
isSwipe= false;
break;
}
return false;
}
});
Now this code
works when I am not using AndroidPDF, but when I replace the content_frame in my layout with a ReaderController to show a pdf, the touch on the screen no longer goes to the mDrawerLayout because the ReaderController's onTouch returns true. I need it to return false so that the mDrawerLayout can receive a touch, but then the scrolling does not work.
I hope this makes it more clear. How does the PDFView's touch work? I'm guessing that the ViewGroup implements a strange onInterceptTouchEvent that makes this whole thing act weirdly. Is there any way that I can get the mDrawerLayout to receive onTouch events, while also keeping the PDFView's swipe-to-turn-a-page functionality?