Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwipeRefreshLayout not showing horizontal progress

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 enter image description here

But i want like this enter image description here

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);
like image 358
Rakki s Avatar asked Apr 08 '15 10:04

Rakki s


People also ask

How do you make a horizontal progress bar?

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.

How to add swipe refresh layout?

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 .

What is swipe refresh layout?

Android SwipeRefreshLayout is a ViewGroup that can hold only one scrollable child. It can be either a ScrollView, ListView or RecyclerView.

How to disable pull to refresh in android studio?

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.


1 Answers

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.

like image 169
Mike Avatar answered Sep 28 '22 14:09

Mike