Proger Progerov
Proger Progerov

Reputation: 175

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

Upvotes: 16

Views: 15549

Answers (4)

Mohamed Slimane
Mohamed Slimane

Reputation: 311

This Is My Example

webframe = WebView

swipeContainer = swipeLayout

swipeContainer.setOnRefreshListener {
        webframe.reload()
        swipeContainer.setColorSchemeColors(Color.WHITE)
        swipeContainer.setProgressBackgroundColorSchemeColor(Color.rgb(0,165,165))
    }

Upvotes: 5

Carlos Daniel
Carlos Daniel

Reputation: 2729

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

Upvotes: 2

Vipul Divyanshu
Vipul Divyanshu

Reputation: 196

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.

Upvotes: 2

Akash
Akash

Reputation: 23

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.

Upvotes: 1

Related Questions