On a ListView
, the SwipeRefreshLayout
works fine. However, on a LinearLayout
only (without ListView
) the behaviour is bizarre. The SwiperefreshLayout's
progress bar doesn't appear completely, in fact, it just appears for a fraction of second. What can the issue be?
Using Linear Layout Inside Relative Layout With Example In Android Studio. Linear Layout can be used inside relative layout since one layout can be nested in other layout in XML.
Android SwipeRefreshLayout is a ViewGroup that can hold only one scrollable child. It can be either a ScrollView, ListView or RecyclerView. The basic need for a SwipeRefreshLayout is to allow the users to refresh the screen manually. This is pretty common in the Facebook Newsfeed screen.
Most of what can be achieved in LinearLayout and RelativeLayout can be done in ConstraintLayout.
Add the SwipeRefreshLayout Widget To add the swipe to refresh widget to an existing app, add SwipeRefreshLayout as the parent of a single ListView or GridView . Remember that SwipeRefreshLayout only supports a single ListView or GridView child. You can also use the SwipeRefreshLayout widget with a ListFragment .
In your LinearLayout
which is inside the SwipeRefreshLayout
, set android:clickable="true"
<LinearLayout
android:id="@+id/dummy_view"
android:clickable="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With