Android : Slide a view with respect to listview scrolled in android?

on Friday, September 26, 2014


I am trying to achieve view hiding with respect to the scrolling of a listview.


Like in facebook app:-


1.)When listview is scrolled down, the bottom blue layout (Status, Photo, CheckIn) starts to slide up with respect to the amount of listview scrolled and finally becomes visible


2.)When the listview is scrolled up , the bottom layout slides down and finally invisivble.


3.)When the list is scrolled up and down simultaneously, the layout also slides down and up with respect to it


Now, i am trying to achieve it with translation but the result is not quite the same :-



public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {

final int currentFirstVisibleItem = view.getFirstVisiblePosition();

if (currentFirstVisibleItem > mLastFirstVisibleItem) {
// Scroll down
count = count + 20;
} else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
// Scroll up
count = count - 20;

}
bottom.setTranslationY(count);
mLastFirstVisibleItem = currentFirstVisibleItem;

}


With this code, the view slides but it is not smooth.


0 comments:

Post a Comment