I am using supportv4:22.0.0 to work with SwipeRefreshLayout. Its works fine but it show always a circular kind of progress instead of horizontal way progress .
I have attached the screenshot for better understanding
I have this
But i want like this
Code i am using in Layout
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ptr_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:id="@+id/lv_news_feed_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#dbdfea"
android:dividerHeight="1dp"
android:cacheColorHint="@null"
android:listSelector="#00000000"
/>
</android.support.v4.widget.SwipeRefreshLayout>
Java class
mPullToRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.ptr_layout);
mPullToRefreshLayout.setOnRefreshListener(this);
mPullToRefreshLayout.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
In Android, by default a progress bar will be displayed as a spinning wheel but If we want it to be displayed as a horizontal bar then we need to use style attribute as horizontal. It mainly use the “android. widget. ProgressBar” class.
To add the swipe to refresh widget to an existing app, add SwipeRefreshLayout as the parent of a single ListView or GridView . Remember that SwipeRefreshLayout only supports a single ListView or GridView child. You can also use the SwipeRefreshLayout widget with a ListFragment .
Android SwipeRefreshLayout is a ViewGroup that can hold only one scrollable child. It can be either a ScrollView, ListView or RecyclerView.
To disable the gesture and progress animation, call setEnabled(false) on the view. This layout should be made the parent of the view that will be refreshed as a result of the gesture and can only support one direct child.
I am quite sure it is not possible with this class. You can always review source code to ensure it works as you want . setColorScheme set only color of the ring that is rotating. setColorScheme is now deprecated - so lets see
public void setColorSchemeColors(int... colors) {
ensureTarget();
mProgress.setColorSchemeColors(colors);
}
and in MaterialProgressDrawable:
public void setColorSchemeColors(int... colors) {
mRing.setColors(colors);
mRing.setColorIndex(0);
}
and field
private final Ring mRing;
As you can see there is no classic ProgressBar you wanted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With