0
votes

I have this XML structure:

<ScrollView>
  <RelativeLayout>
   ..........
     <SwipeRefreshLayout>
        <LinearLayout/>
     </SwipeRefreshLayout>
          .....
  </RelativeLayout>
</ScrollView>

I am trying to implement the SwipeRefreshLayout for the LinearLayout but it made my LinearLayout disappear. I have already tried to put the LinearLayout inside a ScrollView, but it still doesn't appear. I can't remove the main parent also. It is necessary to me. Does anyone know how can I implement it?

1

1 Answers

0
votes
  • Use NestedScrollView instead of ScrollView.
  • Add RelativeLayout as Child View instead of LinearLayout.

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android.

DEMO

<?xml version="1.0" encoding="utf-8"?>
<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"
    >

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true">

          <RelativeLayout>
        .....