Question

I am filling a GridView with pictures fetched from URL on a background Thread. So while the images are loading, the TextView below each image is already there, but the image has no width or height. The problem is that using DP is so confusing, I need the images to fill the 2 column grid and I don't know which size is best for it, that doesn't looks to large on lower resolution

Était-ce utile?

La solution

If you want your gridview to have 2 columns, just use the stretchMode to set the width dynamically.

<GridView
    android:id="@+id/gridview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchMode="columnWidth"
    android:numColumns="2" 
    />

You may want to replace android:layout_width="match_parent" by another value if you don't want the gridview to take all the super view's width.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top