2

Here is a gridview: [test_grid.xml]

 <RelativeLayout xmlns:android="http:....."
android:layout_height="match_parent"
android:layout_width="match_parent">

<GridView
android:id="@+id/grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="6"

    android:verticalSpacing="0dp"
    android:horizontalSpacing="0dp"
    android:stretchMode="columnWidth"
    android:gravity="center"

android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
>
  </GridView>
  </RelativeLayout>

and an imageview: image_item.xml

     <RelativeLayout xmlns:android="http:....."
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:layout_width="45dp"
    android:layout_height="45dp"
    android:id="@+id/imageLetter"

    android:padding="0dp" />
  </RelativeLayout>

And in GridAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater)
  mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    if(convertView==null){
        convertView=inflater.inflate(R.layout.item_list,parent,false);
    }

  ImageView imageView=(ImageView)convertView.findViewById(R.id.imageLetter);

    imageView.setImageResource(mThumbIds[position]);

    return imageView;

Problem is: couldn't remove padding around imageview, enter image description here I tried this:

  imageView.setPadding(0,0,0,0);

but no results. Appreciate any help, advice.

newbie
  • 71
  • 1
  • 8

1 Answers1

0

Make changes in your ImageView layout. Give width and height wrap_content instead of xxdp

<RelativeLayout xmlns:android="http:....."
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageLetter"
        android:padding="0dp" />
</RelativeLayout>

My it will work for you.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437