Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the style progerssbar in SwipeRefreshLayout?

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

like image 524
Proger Progerov Avatar asked Nov 27 '14 03:11

Proger Progerov


4 Answers

This Is My Example

webframe = WebView

swipeContainer = swipeLayout

swipeContainer.setOnRefreshListener {
        webframe.reload()
        swipeContainer.setColorSchemeColors(Color.WHITE)
        swipeContainer.setProgressBackgroundColorSchemeColor(Color.rgb(0,165,165))
    }
like image 150
Mohamed Slimane Avatar answered Nov 15 '22 20:11

Mohamed Slimane


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.

like image 29
Akash Avatar answered Nov 15 '22 21:11

Akash


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.

like image 39
Vipul Divyanshu Avatar answered Nov 15 '22 22:11

Vipul Divyanshu


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

like image 34
Carlos Daniel Avatar answered Nov 15 '22 22:11

Carlos Daniel