Read this and this. Attempted to apply the post's answers, but the button remains without margins when I build and run the app. What am I doing wrong?
public class ResultsActivityA extends Activity {
Button button, submitButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...
LinearLayout activityResultsA= new LinearLayout(this);
Button submitButton=new Button(this);
LayoutParams dimensions= new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
activityResultsA.setLayoutParams(dimensions);
LayoutParams viewDimensions= new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
LayoutParams buttonDimensions= new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
buttonDimensions.setMargins(50, 40, 0, 0);
submitButton.setLayoutParams(buttonDimensions);
activityResultsA.setOrientation(LinearLayout.VERTICAL);
submitButton.setText("Home");
submitButton.setId(5555);
activityResultsA.addView(submitButton);
setContentView(activityResultsA);
addListenerOnButton();
}
}