Como definir a margem dinamicamente no Android?
Atualmente estou fazendo um aplicativo android que contém personalizar diálogo de alerta. Ele contém um botão, mas não posso definir a margem para o botão. o código é dado abaixo. O método setmargin não está funcionando
AlertDialog.Builder myDialog = new AlertDialog.Builder(Login.this);
Button button = new Button(Login.this);
button.setText("Send");
LayoutParams buttonLayoutParams
= new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
button.setLayoutParams(buttonLayoutParams);
resetPassword=editText.getText().toString();
LinearLayout layout = new LinearLayout(Login.this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(textView);
layout.addView(editText);
layout.addView(button);
myDialog.setView(layout);