1

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:

enter image description here

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 ?

manhtuan21
  • 614
  • 6
  • 17

3 Answers3

0

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
);
zaheer ahmed
  • 106
  • 1
  • 2
  • 11
0

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>
Abhinav Gupta
  • 2,145
  • 1
  • 13
  • 28
0

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.!

Mayur Dabhi
  • 2,733
  • 2
  • 11
  • 25