这似乎是在的EditText下面的图片太宽。我以为我已经滥用了SDK以某种方式直到确信,否则我不是在寻找一种方式来指定在两侧一定数量的保证金/填充像素的EditText
It seems like the EditText in the image below is too wide. I assume that I have misused the SDK in some way and until convinced otherwise I am not looking for a way to specify some number of margin/padding pixels on the sides of the EditText
.
这一个看起来比较合适。
This one looks more appropriate.
下面是我的code(即创建第一个创建标签,对话):
Here's my code (that creates the first, 'Create Tag', dialog):
final Dao<Tag, Integer> tagDao = getHelper().getTagDao();
final EditText input = new EditText(this);
input.setSingleLine(true);
input.setHint(R.string.create_tag_dialog_hint);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(input);
builder.setTitle(getString(R.string.create_tag_dialog_title));
builder.setPositiveButton(
getString(R.string.create_tag_dialog_positive),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString().trim();
Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show();
Tag tag = new Tag(value);
try {
tagDao.create(tag);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
builder.setNegativeButton(
getString(R.string.create_tag_dialog_negative), null);
builder.show();
对不起,我的职务,并感谢任何有益的意见的长度。
Sorry for the length of the post and thanks for any helpful comments.
刚刚整理这个自己。使用 AlertDialog
的实例,您可以指定的setView
,并通过在间隔参数。这将工作。
Just sorted this myself. Using an instance of AlertDialog
, you can specify setView
and pass in spacing parameters. This will work.
final EditText input = new EditText(this);
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Title");
alertDialog.setMessage("Message");
alertDialog.setView(input, 10, 0, 10, 0); // 10 spacing, left and right
alertDialog.setButton("OK", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Clicked
}
});
alertDialog.show();
编辑:我知道这个问题是旧的,但没有提供任何解决方案
I'm aware this question is old, but no solution was provided.