Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwipeRefreshLayout on a LinearLayout?

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?

like image 853
vinay vyas Avatar asked Aug 26 '15 08:08

vinay vyas


People also ask

Can we use RelativeLayout inside LinearLayout?

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.

What is SwipeRefreshLayout in Android?

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.

Can we use LinearLayout in ConstraintLayout?

Most of what can be achieved in LinearLayout and RelativeLayout can be done in ConstraintLayout.

How do I use swipe refresh layout?

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 .


1 Answers

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">
like image 127
Ishaan Garg Avatar answered Nov 05 '22 06:11

Ishaan Garg