Usman Kurd
Usman Kurd

Reputation: 7013

SwipeRefreshLayout Without Progress Spinner

Is it possible to perform SwipeRefreshLayout functionality without showing progress spinner all together. Right now its working perfectly fine with its default behavior of pull to refresh shows Progress spinner and onRefresh() I hide It. But I want to hide it all together just want to use the pull to refresh functionality but without progress spinner.

Upvotes: 8

Views: 5115

Answers (6)

jihudus
jihudus

Reputation: 1

In addition to Atakan Akar's answer and to enable future swipe refreshing:

// Reduses spinner size to 0
swipeRefreshLayout.setProgressViewEndTarget(false, 0); 
// Turns off layout refreshing status
swipeRefreshLayout.setRefreshing(false);

Upvotes: 0

Maher Abuthraa
Maher Abuthraa

Reputation: 17813

I don't agree with hiding this spinner completely. but untill the loading starts then hiding it. I have in my layout many in-progress UIs .. so what I have done:

app:refreshing="@{vm.loadingUI1  && vm.loadingUI2  && false}">

loadingUI1 is LiveData

With this approach you show interactive loading as action only and it will be hidden immediately when loading-process starts with any component

Upvotes: 0

hmac
hmac

Reputation: 343

swipe_refresh_layout.setProgressViewOffset( false, -200, -200 )

Upvotes: -1

Atakan Akar
Atakan Akar

Reputation: 201

swipeRefreshLayout.setProgressViewEndTarget(false, 0)

Upvotes: 4

Kyriakos Georgiopoulos
Kyriakos Georgiopoulos

Reputation: 567

You can send loader away

yourSwipeToRefresh?.setProgressViewEndTarget(true, -screenHeight)

Upvotes: 0

Usman Kurd
Usman Kurd

Reputation: 7013

After Done some RnD found a solution that may help others who want to achieve such functionality

 try {
        Field f = mSwipeRefreshLayout.getClass().getDeclaredField("mCircleView");
        f.setAccessible(true);
        ImageView img = (ImageView)f.get(mSwipeRefreshLayout);
        img.setAlpha(0.0f);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }

Upvotes: 21

Related Questions