Reputation: 933
I have a problem with the padding of a EditText from an alertDialog. I want it to not touch the sides but it does despite the setPadding I put..
Here's my code:
EditText temp = new EditText(this);
temp.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
temp.setPadding(10, 10, 10, 10);
final EditText input = temp;
new AlertDialog.Builder(LoginActivity.this).setTitle(getString(R.string.login_forgotpw_title))
.setMessage(getString(R.string.login_forgotpw_message)).setView(input)
I thought it would do the job, but here's the result
Thank you
Upvotes: 1
Views: 386
Reputation: 247
Try this :
LinearLayout baseLayout = new LinearLayout(this);
baseLayout.setOrientation(LinearLayout.VERTICAL);
baseLayout.setPadding(10, 10, 10, 10);
EditText temp = new EditText(this);
temp.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
temp.setPadding(10, 10, 10, 10);
final EditText input = temp;
baseLayout.addView(input);
new AlertDialog.Builder(LoginActivity.this)
.setTitle(getString(R.string.login_forgotpw_title))
.setMessage(getString(R.string.login_forgotpw_message))
.setView(baseLayout)
.create()
.show();
Comment if you have issues understanding...
Upvotes: 0
Reputation: 198
You can set margin to edit text, if you tried to set a bigger padding and not worked.
Upvotes: 1
Reputation: 516
I had the same problem. I resolved putting the editText inside a LinearLayout and adding padding to this LinearLayout. I don't know yet how to resolve it without doing that but it works.
Upvotes: 1