2017-07-06 36 views
1

這是我Gridlayout當前的代碼:Android-圖像處於底部

image_list.setLayoutManager(new GridLayoutManager(this, 3, LinearLayoutManager.VERTICAL, true)); 

當我這樣做,所有這些圖像在底部,而不是頂部襯裏。無論如何我可以解決這個問題?謝謝。

+0

你必須reverseLayout布爾設置爲false。 – Abhishek

+0

我沒有得到你,你可以簡單解釋一下。? –

+0

把你的圖像拉代碼參考。 – Abhishek

回答

2

設置reverselayout假

//Like this 
image_list.setLayoutManager(new GridLayoutManager(this, 3, LinearLayoutManager.VERTICAL, false)); 

文檔:

/** 
* @param context Current context, will be used to access resources. 
* @param spanCount The number of columns or rows in the grid 
* @param orientation Layout orientation. Should be {@link #HORIZONTAL} or {@link 
*      #VERTICAL}. 
* @param reverseLayout When set to true, layouts from end to start. 
*/ 
public GridLayoutManager(Context context, int spanCount, int orientation, 
     boolean reverseLayout) { 
    super(context, orientation, reverseLayout); 
    setSpanCount(spanCount); 
} 
+0

如果將其設置爲false,則網格佈局的頂部會顯示最舊的圖片,而新圖片會顯示在底部。無論如何解決這個問題? – Spotz

+0

需要對數組列表進行排序才能實現它。 – Abhishek

+0

我從Firebase提取圖片,如何實現? – Spotz