2015-05-21 30 views
0

我必須創建一個如下所示的佈局。它有一個圖像視圖與下面的列表視圖。帶有ListView的Android ImageView,當用戶試圖向下滾動時ImageView略微向上滾動

我想要的是,當用戶嘗試向下滾動時,首先圖像視圖會向上移動,只留下圖像視圖的一小部分,以便更多地分配給listview。只有在圖像滾動到新位置後,列表視圖纔開始滾動,而不是在此之前。

同樣,當向上滾動時,一旦用戶到達列表視圖的頂部,圖像視圖應該再次向下滾動到完全可見。

有關如何實現此目的的任何建議?謝謝。 enter image description here

回答

0

您可以檢查:https://github.com/Gnod/ParallaxListView 其他:https://github.com/Frank-Zhu/PullZoomView

mListView = (ParallaxScollListView) findViewById(R.id.layout_listview); 
View header = LayoutInflater.from(this).inflate(R.layout.listview_header, null); 
mImageView = (ImageView) header.findViewById(R.id.layout_header_image); 

mListView.setParallaxImageView(mImageView); 
mListView.addHeaderView(header); 

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
     android.R.layout.simple_expandable_list_item_1, 
     new String[]{ 
       "First Item", 
       "Second Item", 
       "Third Item", 
       "Fifth Item", 
       "Sixth Item", 
       "Seventh Item", 
       "Eighth Item", 
       "Ninth Item", 
       "Tenth Item", 
       "....." 
     } 
); 
mListView.setAdapter(adapter); 
+0

完全向上滾動這並不在片段很好地工作 –

0

你試過嗎? 製作自定義ListView。 另一個包含單個Image視圖的佈局(layout_header.xml)(headImage)。將此佈局設置爲列表視圖的第一個對象。

並製作一個customListView.java。您的customlistView.java將如下所示。我已經跳過了基本部分,希望您可以填寫它。

public class CustomListView extends ArrayAdapter<String> { 


public CustomList(Activity context, etc params) { 
    **Your Code 
} 

@Override 
public View getView(int position,View view, ViewGroup parent){ 
    View rowView; 
if (position == 0){ 
     LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     view = inflater.inflate(R.layout.layout_header, parent, false); 

     ImageView bannerImage = (ImageView)rowView.findViewById(R.id.headImage); 

的問題是,在頂部的圖像將與列表

相關問題