lunes, 8 de octubre de 2012

Android Edit text alignment




How to set the EditText aligment in Android to center

EditText t = (EditText)findViewById(R.id.text);
t.setGravity(Gravity.CENTER);
... in xml :
<EditText
   android:id="@+id/text"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
 android:inputType="text"
  />
it makes the EditText inputField entered text centered horizontally
set the t.setGravity(Gravity.RIGHT); or LEFT, that makes entered text left or right alignement.

No hay comentarios:

Publicar un comentario