Question: in my application i am adding image buttons dynamically in linear-layout in scroll-view.but there is no spacing in between the image buttons.can any one help me in giving space between image buttons.
here is my code.

```
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.activity_main, null);

scrollview=(ScrollView)v.findViewById(R.id.scrollview);
LinearLayout ll =( LinearLayout)v.findViewById(R.id.scrollinear);

ImageButton img_travel = new ImageButton(this);

img_travel.setBackgroundResource(R.drawable.travel);

ImageButton img_work=new ImageButton(this);
img_work.setBackgroundResource(R.drawable.work);

ll.addView(img_work);
ll.addView(img_travel);

setContentView(v);

```

Answer: 
For instance:

```
 LinearLayout.LayoutParams layoutParams =    new LinearLayout.LayoutParams(
 LinearLayout.LayoutParams.FILL_PARENT,    LinearLayout.LayoutParams.WRAP_CONTENT);
 layoutParams.setMargins(20, 20, 20, 20);

  ll.addView(img_work, layoutParams);

```
TRy this...

```
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.activity_main, null);

scrollview=(ScrollView)v.findViewById(R.id.scrollview);
LinearLayout ll =( LinearLayout)v.findViewById(R.id.scrollinear);

ImageButton img_travel = new ImageButton(this);

img_travel.setBackgroundResource(R.drawable.travel);

ImageButton img_work=new ImageButton(this);
img_work.setBackgroundResource(R.drawable.work);

View dummyView= new View(this);
LinearLayout.LayoutParams viewParams = new    LinearLayout.LayoutParams(your width in dp, your height in dp);

dummyView.setLayoutParams(viewParams )

ll.addView(img_work);
ll.addView(dummyView);
ll.addView(img_travel);

setContentView(v);

```