0

enter image description hereEverthnig comes correctily but i need to have a vertical gap between this.Please halp me !!

This is my code .

 for(int i=0;i<value1;i++) {
            //Add images
            ImageView image = new ImageView(HomePage.this);
            image.setImageResource(R.drawable.bulb1);
            image.setLayoutParams(new GridView.LayoutParams(85, 85));
            image.setScaleType(ImageView.ScaleType.CENTER_CROP);
            image.setPadding(8, 8, 8,8 );
            image.setAdjustViewBounds(true);
    }
Ishara Asheni
  • 66
  • 1
  • 11

2 Answers2

0

You can add a margin to image like this

GridView.LayoutParams params = new GridView.LayoutParams(85, 85);
params.setMargins(1, 1, 1, 1);
image.setLayoutParams(params);

if you have an ImageView inside of a GridView, you need to supply the method with GridView.LayoutParams like that etc..

Kushal Sharma
  • 5,978
  • 5
  • 25
  • 41
-1

You can add a TextView(add width=10dp and height=Xdp, here X is your required gap between those images) which does not contain any text after every BulbImage. Those TextView will help you to manage gap between images.

You can also add bottom margin to all images.