The Layout after running the programI made a GridView with those 2 class and I want to remove space between images in the screenshot, How can remove these white spaces?
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
/>
$ImageAdapter Class:
public class ImageAdapter extends BaseAdapter{
Context context;
public ImageAdapter(Context context){
this.context=context;
}
@Override
public int getCount() {
return images.length;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
ImageView imageView;
if (view == null){
imageView=new ImageView(context);
imageView.setLayoutParams(new GridView.LayoutParams(120,120));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(3,3,3,3);
}else {
imageView = (ImageView) view;
}
imageView.setImageResource(images[i]);
return imageView;
}
// images
int [] images={
R.drawable.one, R.drawable.two,
R.drawable.three, R.drawable.four,
/*R.drawable.fastfive, R.drawable.fastsix,
R.drawable.fastseven*/
};
}
$Movies Class:
public class MoviesActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movies);
GridView gridView = (GridView) findViewById(R.id.gridview);
gridView.setAdapter(new ImageAdapter(this));
}
}