In this example, We have shared set margins in a LinearLayout programmatically. Java to create a LinearLayout with buttons that fill the screen with margins.
Here is a little code to accomplish it:
LinearLayout ll = new LinearLayout(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
layoutParams.setMargins(30, 20, 30, 0);
Button okButton=new Button(this);
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.