Answers for "how to set layout margin horizontal programmatically"

1

android studio linearlayout set margin

LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);

LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
     LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

layoutParams.setMargins(30, 20, 30, 0);

Button okButton=new Button(this);
okButton.setText("some text");
ll.addView(okButton, layoutParams);
Posted by: Guest on April-01-2020

Code answers related to "how to set layout margin horizontal programmatically"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language