to much space between images in gallery android

2019-07-26 12:52发布

Hello i have an activity that loads lots of images from the drawable folder, and put them in a gallery view from an Adapter. The problem is that there's too much space between this images.

Here's the getView i use:

public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null) { 
            convertView = new ImageView(mContext);
            convertView.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        }
        ImageView iv = (ImageView) convertView;
        iv.setImageResource(mThumbIds[position]);
        return convertView;
    }

Here is my xml layout:

<Gallery android:id="@+id/gallery"
        android:background="#000000"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_alignParentBottom="true"
    />

Is there any way i can get the images to be next to each other without having to create a new view for every image?

Best Regards.

标签: android
1条回答
乱世女痞
2楼-- · 2019-07-26 12:55

Try using android:spacing in the layout file, to decrease space between images.

查看更多
登录 后发表回答