如何在RightCenter位置75对齐文本我试过Amt.setGravity(Gravity.END);和Amt.setGravity(Gravity.RIGHT); 但它仍然在右上方对齐 我做完了
final EditText Amt = new EditText(this);
Amt.setId(20);
Amt.setText("");
Amt.setTextColor(Color.BLACK);
Amt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
Amt.setHint("Amount");
Amt.setPadding(8,8,8,8);
Amt.setSingleLine(false);
Amt.setLines(1);
Amt.setBackgroundResource(R.drawable.text_bg);
Amt.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
Amt.setGravity(Gravity.END);
TourExpenseListDetailRow.addView(Amt);// add the column to the table row here
LinearLayout.LayoutParams params2 = (LinearLayout.LayoutParams)Amt.getLayoutParams();
params2.setMargins(0, 0, 5, 0); //substitute parameters for left, top, right, bottom
params2.gravity = Gravity.RIGHT;
Amt.setLayoutParams(params2);
答案 0 :(得分:1)
在Amt.setGravity(Gravity.END);
button.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
答案 1 :(得分:-3)
是“line-height:pixel”