android studio linearlayout set margin

Solutions on MaxInterview for android studio linearlayout set margin by the best coders in the world

showing results for - "android studio linearlayout set margin"
Tom
22 Jan 2019
1LinearLayout ll = new LinearLayout(this);
2ll.setOrientation(LinearLayout.VERTICAL);
3
4LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
5     LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
6
7layoutParams.setMargins(30, 20, 30, 0);
8
9Button okButton=new Button(this);
10okButton.setText("some text");
11ll.addView(okButton, layoutParams);
12