Reputation: 1420
Just came across this app RetailMeNot Coupons. The list view used is custom and looks pretty cool. Initially, the list show smaller image of a child-item. As the user scrolls up, the child item expands fully to reveal a bigger image.
Out of curiosity, I plan to build a similar list-view in a test app. I am sure this is a custom list-view, has anyone seen a library or implementation of a similar list-view?
Upvotes: 2
Views: 437
Reputation: 1
I have tried directly working with listviewscroll.
Is not perfect but is a start
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getListView().setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
for (int j=0; j<visibleItemCount; j++) {
if(absListView.getChildAt(j).getClass() == FrameLayout.class) {
FrameLayout item = (FrameLayout) absListView.getChildAt(j);
String result = "";
if (item != null) {
RelativeLayout relative1 = (RelativeLayout) item.getChildAt(0);
ImageView promoImage = (ImageView) relative1.getChildAt(0);
View promoOverlay = (View) relative1.getChildAt(1);
RelativeLayout relative2 = (RelativeLayout) relative1.getChildAt(2);
ImageView brandImage = (ImageView) relative2.getChildAt(0);
TextView promoText = (TextView) relative2.getChildAt(1);
item.setLayoutParams(new AbsListView.LayoutParams(item.getWidth(), (int) minHeight));
if (item.getTop() < maxHeight) {
if (item.getTop() >= 0) {
float topPercent = item.getTop() / maxHeight;
float newHeight = minHeight + ((maxHeight - minHeight) * (1 - topPercent));
if (newHeight <= maxHeight) {
item.setLayoutParams(new AbsListView.LayoutParams(item.getWidth(), (int) newHeight));
promoOverlay.setAlpha(topPercent / 2);
} else {
item.setLayoutParams(new AbsListView.LayoutParams(item.getWidth(), (int) maxHeight));
if (item.getTop() > 0) {
promoOverlay.setAlpha(0.5f);
} else {
promoOverlay.setAlpha(0f);
}
}
} else {
float topPercent = (-item.getTop()) / maxHeight;
float newHeight = maxHeight - ((maxHeight - minHeight) * (topPercent));
if (newHeight >= minHeight) {
item.setLayoutParams(new AbsListView.LayoutParams(item.getWidth(), (int) newHeight));
promoOverlay.setAlpha(topPercent / 2);
} else {
item.setLayoutParams(new AbsListView.LayoutParams(item.getWidth(), (int) minHeight));
}
promoOverlay.setAlpha(0);
}
} else {
if (item.getTop() > 0) {
item.setLayoutParams(new AbsListView.LayoutParams(item.getWidth(), (int) minHeight));
promoOverlay.setAlpha(0.5f);
}
}
}
}
}
}
});
}
Upvotes: -1
Reputation: 317
Look at this library
https://github.com/ksoichiro/Android-ObservableScrollView
May be some customization on this library can help you.
Upvotes: 0