I working with SwipeRefreshLayout. Here what my need is... Im using one Linearlayout inside SwipeRefreshLayout which is in "RED COLOR". when im trying to pull down that layout, that layout is not moving. Only its showing that refresh circular arrow, But i want to pull down that whole "Red color" layout. How to achieve this?
Please find my sources for reference.
Suggestion please....
mylayout.xml
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout_emptyView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#ff0000"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sample SwipeRefreshLayout"
android:layout_marginTop="50dp"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
MyClass.java
public class MyClass extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
private SwipeRefreshLayout swipeLayout;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.mylayout,null);
swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout_emptyView);
onCreateSwipeToRefresh(swipeLayout);
return view;
}
private void onCreateSwipeToRefresh(SwipeRefreshLayout swipeLayout) {
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorSchemeColors(android.R.color.holo_green_dark, android.R.color.holo_red_dark,
android.R.color.holo_blue_dark, android.R.color.holo_orange_dark);
}
@Override
public void onRefresh() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}