【发布时间】:2015-12-30 00:46:09
【问题描述】:
我将下面的代码用于弹出警报框,其中包含EditText。我正在使用边距来对齐下面代码中的EditText。问题是我用于一个设备或模拟器的边距数字将在其他设备或模拟器上关闭。如果我正确对齐一个设备,它会在另一台设备上看起来关闭。任何帮助表示赞赏。
AlertDialog.Builder aBuilder = new AlertDialog.Builder(ExpenseSheet.this);
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(85, 0, 50, 0);
// Set up the input
final EditText input = new EditText(ExpenseSheet.this);
//FOCUSING ON POPUP WINDOW TEXT
input.requestFocus();
layout.addView(input, params);
// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
//limiting the amount of characters
input.setFilters(new InputFilter[]{new InputFilter.LengthFilter(8)});
aBuilder.setView(layout);
【问题讨论】:
标签: android android-edittext alignment