Reputation: 3430
I' m using SwipeRefreshLayout in a Fragment inside an Activity. It work fine when i'm swipe down but when first time Fragment create and load data. It just has a blank circle without animation load arrow , like this:
My code show SwipeRefreshLayout :
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.item_order_fragment, container, false);
ButterKnife.bind(this, v);
mSwipeRefreshLayout.setOnRefreshListener(this);
mSwipeRefreshLayout.setColorSchemeResources(R.color.startColorPrimary,
R.color.color_tab_selected,
R.color.endColorPrimary);
mSwipeRefreshLayout.setRefreshing(true);
return v;
}
@Override
public void onRefresh() {
// Fetching data from server
}
My xml layout :
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tv_order_status_explain"
android:background="@android:color/transparent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_orders"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
tools:listitem="@layout/item_customer_order" />
</android.support.v4.widget.SwipeRefreshLayout>
I has try every solution in this SwipeRefreshLayout setRefreshing() not showing indicator initially but nothing work. Can anyone helps me with this ?
Upvotes: 2
Views: 517
Reputation: 46460
I had the same issue. It turned out that the "load" was taking too little time, so the circular progress bar had no time to animate in.
Make sure that your background operations takes at least a second for testing, e.g. by adding artificial Thread.sleep(1000);
somewhere in a background thread, or delay(1000)
in a Coroutines suspend
function.
Upvotes: 0
Reputation: 3926
i think your accent colour is white and there circle background also white that why is not visible, try to change it from folder of value/color.xml file. there is ColourAccent change it. should work.!
Upvotes: 0
Reputation: 2265
Try this :
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_order_status_explain">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_orders"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
tools:listitem="@layout/item_customer_order" />
</android.support.v4.widget.SwipeRefreshLayout>
and do this in java class :
mSwipeRefreshLayout.setColorSchemeResources(R.color.orange, R.color.green, R.color.blue);
mSwipeRefreshLayout.setOnRefreshListener(this);
and do this in color.xml :
<color name="orange">#FF9900</color>
<color name="green">#009900</color>
<color name="blue">#000099</color>
Upvotes: 0
Reputation: 198
The problem is that setColorSchemeColors() needs color integers as inputs like Color.BLUE, not color resource IDs.
So to show color of arrow Code should be like :
swipeRefreshLayout.setColorSchemeColors(Color.BLACK,
Color.BLUE,
Color.GREEN,
Color.GRAY
);
and for setting color resource IDs code should be like :
swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light
);
Upvotes: 1