How to set margin dynamically in Android?
<p>I am currently doing an android application that contains customize alert dialog. It contains  a button , but i can't set the margin for the button . the code is given below. setmargin method is not working </p>

<pre><code>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);
</code></pre>
