SwipeRefreshLayout с NestedScrollView без прокрутки - PullRequest
0 голосов
/ 12 декабря 2018

Я хотел бы показать ListView внутри прокрутки.Кажется, это работает до добавления макета SwipeRefresh.После его добавления обновление работает, но я больше не могу прокручивать.

Я полагаю, что проблема связана с кодом XML.Обратите внимание, что если я использую обычный ScrollView, я могу сделать и то, и другое, но не могу прокрутить назад, потому что активируется SwipeRefresh.

Вот мой код XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_favorites"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="?attr/actionBarSize"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:layout_marginBottom="60dp"
            android:id="@+id/friends_scrollLayout"
            android:layout_below="@id/friends_search">

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/favorite_horeca_scrollview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:fillViewport="true"
            android:scrollbars="none"
            android:scrollingCache="true">

            <LinearLayout
                android:id="@+id/favorite_horeca_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <ListView
                    android:id="@+id/favorite_horeca_list"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:dividerHeight="-1dp" />

            </LinearLayout>

        </android.support.v4.widget.NestedScrollView>

        </LinearLayout>

    </android.support.v4.widget.SwipeRefreshLayout>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/empty"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F5F7F8"
    android:visibility="gone"
    >

    <ImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_centerInParent="true"
        android:layout_above="@id/empty_text"
        android:layout_marginBottom="20dp"
        android:gravity="center_vertical|center_horizontal"
        android:src="@drawable/ic_logo_vert_rond"
        />

    <TextView
        android:id="@+id/empty_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="No Horecas added to your favorites."
        android:gravity="center_horizontal|center_vertical"/>

</RelativeLayout>

Ответы [ 2 ]

0 голосов
/ 12 декабря 2018

Решением было просто полностью удалить Scrollview, нет необходимости добавлять его, SwipeRefreshLayout уже имеет встроенный Scroll.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
>

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_favorites"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="?attr/actionBarSize"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <ListView
                android:id="@+id/favorite_horeca_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:dividerHeight="-1dp" />

</android.support.v4.widget.SwipeRefreshLayout>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/empty"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F5F7F8"
    android:visibility="gone"
    >

    <ImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_centerInParent="true"
        android:layout_above="@id/empty_text"
        android:layout_marginBottom="20dp"
        android:gravity="center_vertical|center_horizontal"
        android:src="@drawable/ic_logo_vert_rond"
        />

    <TextView
        android:id="@+id/empty_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="No Horecas added to your favorites."
        android:gravity="center_horizontal|center_vertical"/>

</RelativeLayout>

0 голосов
/ 12 декабря 2018
<CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_favorites"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="?attr/actionBarSize"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/favorite_horeca_scrollview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:fillViewport="true"
            android:scrollbars="none"
            android:scrollingCache="true">

            <LinearLayout
                android:id="@+id/favorite_horeca_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <ListView
                    android:id="@+id/favorite_horeca_list"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:dividerHeight="-1dp" />

            </LinearLayout>

        </android.support.v4.widget.NestedScrollView>

    </android.support.v4.widget.SwipeRefreshLayout>


<RelativeLayout
    android:id="@+id/empty"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F5F7F8"
    android:visibility="gone"
    >

    <ImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_centerInParent="true"
        android:layout_above="@id/empty_text"
        android:layout_marginBottom="20dp"
        android:gravity="center_vertical|center_horizontal"
        android:src="@drawable/ic_logo_vert_rond"
        />

    <TextView
        android:id="@+id/empty_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="No Horecas added to your favorites."
        android:gravity="center_horizontal|center_vertical"/>

 </RelativeLayout>

</CoordinatorLayout >

Попробуйте вот так

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...