16

I use SwipeRefreshLayout to update my list.

everything works. but I do not like the progress bar. It is round. and carried the arrow to spin. I have seen examples in which a strip of moving from the center to the edges. How to set up a progress bar style?

private SwipeRefreshLayout swipeLayout;
...
swipeLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_guest_list);
        swipeLayout.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE, Color.CYAN);
        swipeLayout.setOnRefreshListener(this);

example I need both the video

Proger Progerov
  • 175
  • 1
  • 1
  • 8
  • 1
    SwipeRefreshLayout UI has been changed on new material design pattern (http://www.google.com/design/spec/patterns/swipe-to-refresh.html) without giving choice to choose. Please check http://stackoverflow.com/questions/24995480/android-l-material-design-on-swiperefreshlayout-color-scheme – Yogesh Narayanan Nov 27 '14 at 04:17
  • Yes, exactly what I have up and running. What do I do if I want a progress bar like in the old version? I am not absolutely satisfied with circular progressbar – Proger Progerov Nov 27 '14 at 04:56
  • I hope (atleast now) the only way to get the old style SwipeRefreshLayout is to get the file(s) from the AOSP version control system – Yogesh Narayanan Nov 27 '14 at 05:07
  • I measured with this style (yet) but I can not set the transparency background on the progress bar! can you help? do not want to start a new topic. swipeLayout.setProgressBackgroundColor(Color.RED); an error! android.content.res.Resources$NotFoundException: Resource ID #0xffff0000 – Proger Progerov Nov 27 '14 at 05:34
  • setProgressBackgroundColor only accepts resource id of the color and not the color id. Put the necessary color in colors.xml and get it as getResources().getColor(R.color.XXX) – Yogesh Narayanan Nov 27 '14 at 05:51
  • swipeLayout.setProgressBackgroundColor(getActivity().getResources().getColor(R.color.employe_negative)); so I did too. The same error – Proger Progerov Nov 27 '14 at 06:06
  • Check swipeLayout.setProgressBackgroundColor(R.c‌​olor.employe_negative); also let me know the color xml of employe_negative – Yogesh Narayanan Nov 27 '14 at 06:20
  • swipeLayout.setProgressBackgroundColor(android.R.color.darker_gray); so works – Proger Progerov Nov 27 '14 at 07:56
  • Possible duplicate of [SwipeRefreshLayout: Swipe progress animation](http://stackoverflow.com/questions/24099755/swiperefreshlayout-swipe-progress-animation) – dramzy Nov 17 '15 at 04:39

4 Answers4

5

This Is My Example

webframe = WebView

swipeContainer = swipeLayout

swipeContainer.setOnRefreshListener {
        webframe.reload()
        swipeContainer.setColorSchemeColors(Color.WHITE)
        swipeContainer.setProgressBackgroundColorSchemeColor(Color.rgb(0,165,165))
    }
Mohamed Slimane
  • 311
  • 3
  • 14
2

You can actually change it to the older progress bar one, by giving reference to the older jar file of the support-v4 library. I had the same issue suddenly after updating eclipse, i just copied the older support-v4.jar to projects libs folder and then using project properties references this support-v4.jar and then clean and built the project and now it was using the old classes. This solution is suitable if you are not using anything particular from the updated support library.

Vipul Divyanshu
  • 196
  • 2
  • 6
2

You can play with different colors of the swipe's progress var:

swipeRefreshLayout.setColorSchemeResources(R.color.blue, R.color.green, R.color.orange);

where blue, green and orange are defined in colors.xml

setColorSchemeResources receives a varargs, so you can play with the number of colors there

Carlos Daniel
  • 2,459
  • 25
  • 30
1

You can't change the animation.

In SwipeRefreshLayout you can't customize much; I believe this is an attempt of Google to get developers stick to common patterns. What you can style are the four colors of the animation, specified with setColorScheme().

SwipeRefreshLayout takes care to show its predefined animation at its top for you. This can be when canChildScrollUp() returns false and user 'pulls down', or when you set setRefreshing(true). Turn off the animation with setRefreshing(false). Put your logic in the method onRefreshing() of the listener. Override canChildScrollUp() if you put something that is not a ListView in your SwipeRefreshLayout. You should be good to go from here.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Akash
  • 23
  • 8
  • 5
    This is copied verbatim from the accepted answer on [this question](http://stackoverflow.com/questions/24099755/swiperefreshlayout-swipe-progress-animation) – dramzy Nov 17 '15 at 04:38