Lowteast
Lowteast

Reputation: 161

Button android, text position

I create some buttons in my java code. The probleme is the text that i create for this button is always center, do you know how to change is position. I've search and no found because i create it in the java code, not in the xml

 Button moncasier = new Button (this);
  moncasier.setText("casier numéro :"+i);
  moncasier.setTextSize(30);

  moncasier.setBackground(getResources().getDrawable(R.drawable.img_casier));
  layoutDesCasiers = (LinearLayout)findViewById(R.id.affichecasier);
  layoutDesCasiers.addView(moncasier);

Thanks for the time you spend to me and sorry for my bad english

Upvotes: 0

Views: 3768

Answers (1)

Nathua
Nathua

Reputation: 8826

moncasier.setGravity(Gravity.BOTTOM);

you can use gravity for text alignment, Bottom is an example above.

Upvotes: 6

Related Questions