Reputation: 31
I have a listview for my android app and I want to make an animation at the top of the list view when the user over scrolls like one the one for the instagram or twitter app. How would I go about this. Is there a method that is called when the user over scrolls and I was thinking about using a frameanimation for the actually animation.
Upvotes: 1
Views: 276
Reputation: 6187
You can add a swipe refresh layout on your xml file:
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/favs_refresher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ListView
android:id="@+id/favs_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</android.support.v4.widget.SwipeRefreshLayout>
Then on your activity:
swipeRefresher = (SwipeRefreshLayout)findViewById(R.id.favs_refresher);
swipeRefresher.setOnRefreshListener(this);
Be sure that your activity implements SwipeRefreshLayout.OnRefreshListener
then you can make use of the onRefresh()
method:
@Override
public void onRefresh() {
//do something
}
Upvotes: 2