问题
I'm attempting to use the DrawerLayout to display two fragments with the slideout fragment having a listview. I'm mostly following the example found on the developers site.
I have everything almost working, however when scrolling through the listview, any left or right movements in the scrolling motion will cause the scrolling to be interrupted and the drawerLayout to move horizontally.
Layout
fragment A
-------------------------------------
| | |
| | |
| | |
| Content Fragment | Fragment A |
| | |
| | (ListView) |
| | |
| | |
| | |
--------------------------------------
My Activity.xml
<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">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<FrameLayout
android:id="@+id/drawer_right"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="right"/>
</android.support.v4.widget.DrawerLayout>
FragmentA.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="320dp"
android:layout_height="match_parent"
android:background="@color/lightGray">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ExpandableListView
android:id="@+id/expandableListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@null"/>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
I don't have this problem if I use a normal ListView with the DrawerLayout, is there a way to stop the DrawerLayouts onTouch events from firing while my Listview is currently scrolling? I've tried setting setting my Fragment's rootview to be clickable = true, which didn't work.
Any suggestions would greatly be appreciated!
回答1:
It turns out the SwipeRefreshLayout was causing my scrolling issue. Removing the layout and using a separate 3rd party library fixed the issue for me.
Here's an open ticket on the SwipeRefreshLayout: https://code.google.com/p/android/issues/detail?id=69074
来源:https://stackoverflow.com/questions/23838120/vertical-scrolling-interrupted-by-oversensitive-drawerlayout-when-using-drawerla