Nidhin Sasankan Nidhin Sasankan - 1 month ago 22
Android Question

Progressbar shows larger in Swiperefreshlayout

I have tabview with listview, progressbar showing very large in the listview, I tried to set 30dp to width and height and also match_parent but not working. The progressbar is loading in onPreexecure method.

here is my listview.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ProgressBar>

<android.support.v7.widget.RecyclerView
android:id="@+id/recycleView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</android.support.v4.widget.SwipeRefreshLayout>


Here is my output screenshot
enter image description here

Answer

In the SwipeRefreshLayout class it says

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. This view will also be made the target of the gesture and will be forced to match both the width and the height supplied in this layout.

So try adding a Relative layout after the SwipeRefreshLayout and put the rest of the code inside it

Comments