-1

something similar to image that on call of SwipeRefreshLayoutListener my whole layout should go down I want to move the whole layout down when SwipeRefreshLayout Listener is called? Is this thing possile in android .? This is my whole xml layout.SwipeRefreshLayout contains a progressbar and FrameLayout and that is included in a RelativeLayout.So I want the FrameLyout should pull down when I call for refresh.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_navigation_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
       >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar_layout" />

            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swipeRefresh"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/toolbar">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <ProgressBar
                        android:id="@+id/horizontal_sync_progress"
                        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:background="@color/gradient_bg_end"
                        android:indeterminateDrawable="@drawable/progress_drawable"
                        android:progressDrawable="@drawable/progress_drawable"
                        android:visibility="gone"/>

                    <FrameLayout
                        android:id="@+id/container_frag"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />
                </LinearLayout>
            </android.support.v4.widget.SwipeRefreshLayout>
        </RelativeLayout>

        </android.support.v4.widget.DrawerLayout>
</LinearLayout>
Divya
  • 121
  • 2
  • 11

2 Answers2

1
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

 <android.support.v4.widget.SwipeRefreshLayout
                    android:id="@+id/swp1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

<-----Your design here------>

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

</RelativeLayout>

try this. you have to set your SwipeRefreshLayout above. Hope it helps you. If this doesn't helps you ask me what is the problem i will help you

And My class code is below

    mSwipeRefreshLayout1 = (SwipeRefreshLayout) findViewById(R.id.swp1);
            //set colors if you need 
mSwipeRefreshLayout1.setColorSchemeResources(R.color.colorPrimary, R.color.colorPrimaryDark, R.color.colorPrimaryLight);
            mSwipeRefreshLayout1.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                @Override
                public void onRefresh() {
                    mSwipeRefreshLayout1.setRefreshing(true);
                    try {

                        //Refresh data

                    } catch (Exception e) {
                        //Toast.makeText(getActivity(), String.valueOf(e.getMessage()), Toast.LENGTH_SHORT).show();
                        //customtoast.ShowToast(getActivity(), String.valueOf(e.getMessage()), R.layout.red_toast);
                    }
                }
            });
Zaki Pathan
  • 1,762
  • 1
  • 13
  • 26
0

you can code like this

   swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            new class(getActivity(), listView, progressBar, mApp.getPreference().getString(Common.u_id, ""), "all", swipe).execute();
        }
    });
    return view;
}

Include code below in your xml file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    //your xml codes
   </RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Nazim ch
  • 834
  • 8
  • 20