Reputation: 119
I have the following GridView:
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/gridView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:numColumns="3" />
Which I populate with this type of items:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"/>
</LinearLayout>
I set the image in the adapter by setting a bitmap. The images get the appropriate size for a GridView with 3 columns, but the items are way too high. This means that there is a lot of empty space above and below every image. How can I remove that space so the items have the same height as the images?
Here's an illustration of how it is right now:
Upvotes: 0
Views: 86
Reputation: 2962
Add this in xml,
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:id="@+id/imageView"/>
Upvotes: 1