Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the drawable used in SwipeRefreshLayout be changed?

Is it possible to change the default progress drawable in SwipeRefreshLayout to a custom drawable?

If yes, will I lost the rotation/animation or other property?

The said drawable

like image 384
pablobaldez Avatar asked Nov 27 '14 18:11

pablobaldez


1 Answers

mSwipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.your_swiperefresh_id);
try {
    Field f = mSwipeRefreshLayout.getClass().getDeclaredField("mCircleView");
    f.setAccessible(true);
    ImageView img = (ImageView)f.get(mSwipeRefreshLayout);
    img.setImageResource(R.drawable.your_drawable_file);
} catch (NoSuchFieldException e) {
    e.printStackTrace();
} catch (IllegalAccessException e) {
    e.printStackTrace();
}
like image 188
Nik Avatar answered Sep 20 '22 17:09

Nik