同时使用 SwipeRefreshLayout 和 DrawerLayout 失去 listview 功能?
Lose listview function using both SwipeRefreshLayout and DrawerLayout?
我在同一 xml 中同时使用 SwipeRefreshLayout 和 DrawerLayout。但是抽屉工作正常。但我无法滑动列表视图。 xml有什么问题吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.einverne.inoreader.Activity.MainActivity">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_below="@+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar"></ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false" />
<fragment
android:id="@+id/fragment_drawer"
android:name="com.einverne.inoreader.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
我把我的layout.xml改成这个来解决问题:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- The navigation drawer -->
<com.einverne.inoreader.ScrimInsetsFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrimInsetsFrameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="10dp"
android:fitsSystemWindows="true">
<!-- The navigation drawer content -->
</com.einverne.inoreader.ScrimInsetsFrameLayout>
<!-- The main content -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_below="@+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar"></ListView>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
</LinearLayout>
<fragment
android:id="@+id/fragment_drawer"
android:name="com.einverne.inoreader.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
我在同一 xml 中同时使用 SwipeRefreshLayout 和 DrawerLayout。但是抽屉工作正常。但我无法滑动列表视图。 xml有什么问题吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.einverne.inoreader.Activity.MainActivity">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_below="@+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar"></ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false" />
<fragment
android:id="@+id/fragment_drawer"
android:name="com.einverne.inoreader.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
我把我的layout.xml改成这个来解决问题:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- The navigation drawer -->
<com.einverne.inoreader.ScrimInsetsFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrimInsetsFrameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="10dp"
android:fitsSystemWindows="true">
<!-- The navigation drawer content -->
</com.einverne.inoreader.ScrimInsetsFrameLayout>
<!-- The main content -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_below="@+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar"></ListView>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
</LinearLayout>
<fragment
android:id="@+id/fragment_drawer"
android:name="com.einverne.inoreader.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>