How can I align the text in RightCenter position 75 I hade tried Amt.setGravity(Gravity.END); and Amt.setGravity(Gravity.RIGHT); but it still top right aligned I have done
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);
Use center on your Amt.setGravity(Gravity.END);
EDIT, Like this:
button.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
在CSS中是“行高:像素”
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.