Android‎ > ‎

Adding Spaces between Dynamically Added buttons

posted Dec 12, 2012, 11:42 PM by Akash Khaitan   [ updated Mar 9, 2013, 7:23 AM ]

Set the Margin for the layout parameter which is to be used for button in order to add spaces outside button
The below code adds a top space to button

Button button=new Button(activity);

//Setting Layout Parameters
.LayoutParams params = new LinearLayout.LayoutParams(buttonWidth, buttonHeight); params.setMargins(0, 10, 0, 0);

//Setting button parameters