Help to figure out how to do this: There is a list of something, for example, news and at the top of this list there is a picture, which if I make a swipe down, it will increase and a new batch of news will load. Tell me how to make the increase itself when svaype down, I can not think of anything. In the pictures, what I need approximately

enter image description here

enter image description here

UPD:

Thanks pavlofff for the link. But I can't do SwipeRefreshLayout with StretchLayout . I tried many races, but the error. Here is my xml

 <menuobject.StretchLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipe" android:layout_width="wrap_content" android:layout_height="match_parent" > <ImageView android:id="@+id/menuImageI" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="centerCrop" /> <RelativeLayout android:id="@+id/front_view" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f1f1f1" android:orientation="vertical" > <ListView android:id="@+id/listCategoryMenu" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbars="vertical" /> </RelativeLayout> </android.support.v4.widget.SwipeRefreshLayout> </menuobject.StretchLayout> 

In the StretchLayout class StretchLayout changed the lines:

  mStretchView = getChildAt(0); mFrontView = getChildAt(1); 

on

 mStretchView = getChildAt(1); mFrontView = getChildAt(2); 

And errors:

 06-09 23:33:02.597: E/AndroidRuntime(20015): FATAL EXCEPTION: main 06-09 23:33:02.597: E/AndroidRuntime(20015): java.lang.NullPointerException 06-09 23:33:02.597: E/AndroidRuntime(20015): at menuobject.StretchLayout.onLayout(StretchLayout.java:68) 06-09 23:33:02.597: E/AndroidRuntime(20015): at android.view.View.layout(View.java:11315) 06-09 23:33:02.597: E/AndroidRuntime(20015): at android.view.ViewGroup.layout(ViewGroup.java:4314) 06-09 23:33:02.597: E/AndroidRuntime(20015): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1633) 

68 line:

 mMargin = mStretchView.getMeasuredHeight()*mRatio; 
  • one
    You need the following logic: the picture below is a list. When the list reaches the top, the image is stretched and the contents of the list are updated? Then, unfortunately, StretchLayout will not StretchLayout I changed the answer, uncheck that it is correct, if this option does not suit you. - pavlofff
  • @pavlofff I understood, thanks - nesalexy

2 answers 2

Since for the SwipeRefreshLayout widget to work SwipeRefreshLayout only three types of elements can be nested in it: ScrollView , ListView , GridView , I suggest using the external library ObservableScrollView , which widgets are inherited from the three listed elements. This should work correctly.
Otherwise, you will need to implement a custom component to implement the update.

  • Thank you very much, very cool done! It would be even cooler if it were api13 and not 14 - nesalexy
  • ahh ... thanks, got it! - nesalexy
  • @nesalexy Please delete the comments, they no longer correspond to the answer. - pavlofff

Very good library, will help you! https://android-arsenal.com/details/1/1900

  • one
    Try to write more detailed answers. At a minimum, specify the name of the library. You can also give code examples. - Athari