【发布时间】: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