2015-03-25 44 views
2

刚刚遇到这个应用程序RetailMeNot Coupons。使用的列表视图是自定义的,看起来很酷。最初,该列表显示较小的子项目图像。随着用户向上滚动,子项目完全展开以显示更大的图像。Android:像RetailMeNot应用程序的ListView

出于好奇,我打算在测试应用程序中构建一个类似的列表视图。 我确定这是一个自定义列表视图,有没有人看过类似列表视图的库或实现?

List Position 1

List Position 2

List Position 3

+0

可能这是一个混合的应用程序。 – Apurva 2015-03-25 07:34:16

+0

它不是Hybrid应用程序它的anroid的本地应用程序@Apurva – 2015-05-23 05:32:54

+0

@Faheem你实现了这个吗? – 2015-05-23 05:33:32

回答

-1

我试过直接使用listviewscroll。

是不完美的,但是是一个开始

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); 
          } 
         } 

        } 
       } 
      } 
     } 
    }); 

} 
相关问题