【问题标题】:Vertical Scrolling Interrupted by Oversensitive DrawerLayout When Using DrawerLayout with a ListFragment使用带有 ListFragment 的 DrawerLayout 时,垂直滚动被过度敏感的 DrawerLayout 中断
【发布时间】:2014-05-23 20:49:34
【问题描述】:

我正在尝试使用 DrawerLayout 显示两个片段,其中滑出片段具有列表视图。我主要遵循developers site 上的示例。

我几乎可以正常工作,但是当滚动列表视图时,滚动动作中的任何左右移动都会导致滚动中断并且抽屉布局水平移动。

布局

             fragment A
-------------------------------------
|                       |            |
|                       |            |
|                       |            |
|   Content Fragment    | Fragment A | 
|                       |            |
|                       | (ListView) |
|                       |            |
|                       |            |
|                       |            |
--------------------------------------

我的活动.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>

片段A.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>

如果我使用带有 DrawerLayout 的普通 ListView 就没有这个问题,有没有办法在我的 Listview 当前滚动时阻止 DrawerLayouts onTouch 事件触发?我尝试将 Fragment 的 rootview 设置为 clickable = true,但没有成功。

任何建议将不胜感激!

【问题讨论】:

    标签: android android-layout expandablelistview drawerlayout


    【解决方案1】:

    事实证明 SwipeRefreshLayout 导致了我的滚动问题。删除布局并使用单独的第 3 方库为我解决了这个问题。

    这是 SwipeRefreshLayout 上的一张公开票:https://code.google.com/p/android/issues/detail?id=69074

    【讨论】:

      猜你喜欢
      • 2013-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-28
      相关资源
      最近更新 更多