2015-07-21 119 views
4

我做了大量的谷歌,並發現了很多例子,並探討,但〜我想AsymmetricGridView不同的圖像和不同的圖像大小在我的網格。如何在行中創建具有不同圖像大小的AsymmetricGridView

請根據我的要求找到下面的圖片。

enter image description here

請幫我爲這種類型的網格或建議我庫的這種類型的非對稱電網。

在此先感謝。

+0

你好@Arvind ......沒有u得到你的問題的解決方案...請讓我know..because我有也被困在這個問題..感謝 –

回答

2
+0

我試過這個,但根據我的問題第二和第三行是不可能在這個庫。 –

+0

看一看圖庫的截圖,是不是和你貼的圖片一樣 – Sharj

+0

不,看看我的第一排和上面的圖像是一樣的,但是第二排有一個小的和一個大的圖像,第三排只有一個一個圖像 –

2

您可以使用​​在Eclipse工作空間來實現你的goal.Import此lib或在您的gradle這個,如果你使用的是Android工作室

在您的build.gradle文件中:

dependencies { 
    compile 'com.felipecsl.asymmetricgridview:library:2.0.1' 
} 

在您的佈局XML:

<com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/listView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

在您的活動類:

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    listView = (AsymmetricGridView) findViewById(R.id.listView); 

    // Choose your own preferred column width 
    listView.setRequestedColumnWidth(Utils.dpToPx(this, 120)); 
    final List<AsymmetricItem> items = new ArrayList<>(); 

    // initialize your items array 
    adapter = new ListAdapter(this, listView, items); 
    AsymmetricGridViewAdapter asymmetricAdapter = 
     new AsymmetricGridViewAdapter<>(this, listView, adapter); 
    listView.setAdapter(asymmetricAdapter); 
} 
+0

我試過這個,但根據我的問題第二和第三行是不可能在這個庫。可以請讓我知道這件事是可能的,根據我的要求 –

+0

我看到這個庫在github上,這正是我所需要的,但我不能遵循如何使用他的庫來加載動態圖像..在我的項目中,圖像是從服務器獲取的。所以我從服務器獲取圖像的URL。我可以將它們存儲在列表中,但是如何使用AsymmetricGridView來實現它。你可以ü我這個wid這個 - http://stackoverflow.com/questions/31792625/displaying-dynamic-images-in-asymmetricgridview –

+0

@ BhuvneshVarma.if你仔細分析庫,看看AsymmetricGridViewAdapter已擴展BaseAdapter.So它就像一個正常的GridView.Just獲取您的數據,將其傳遞到您的適配器並使用圖像加載庫(如Picasso)(http://square.github.io/picasso/)將您的項目加載到圖像視圖中。 –

相關問題