Add bigger margin to EditText in Android AlertDialog

final AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity);
final EditText input = new EditText(thisActivity);
input.setSingleLine();
FrameLayout container = new FrameLayout(thisActivity);
FrameLayout.LayoutParams params = new  FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
input.setLayoutParams(params);
container.addView(input);
alert.setTitle("by...");
alert.setMessage("test message");
alert.setView(container);

Make sure you add another line to your dimens.xml resource file, such as

<dimen name="dialog_margin">20dp</dimen>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)