I'm trying to fill a LinearLayout / Relative, whatever, with many images. Uncontable.
This is my implementation:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/header"
android:layout_centerHorizontal="true" >
<LinearLayout
android:id="@+id/marcasImages"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</LinearLayout>
</ScrollView>
So I add a same image multiple times:
for (int i=0; i<10; i++){
ImageView imatgeExemple = new ImageView(this.getApplicationContext());
imatgeExemple.setImageResource(R.drawable.imageexample);
contenidorImatgesGaleria.addView(imatgeExemple);
}
contenidorImatgesGaleria
is marcasImages
.
But what I'm getting as a result is a single row of X images (X = as many images as it can fill by its resolution). So for example, if I do that loop for 1k times, only 4 images are shown.
I'd like to have as many rows as needed.
This is what's happening:
And this is what I'm trying to achieve:
I've tried to use GridLayout
but nothing changed.
<GridLayout
android:id="@+id/marcasImages"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</GridLayout>
Any idea of which layout should I use?