I am trying to Display a text box with letters separated by spaces.
EditText wordText = (EditText) findViewById(R.id.word_text);
wordText.setPaintFlags(wordText.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
InputFilter[] filterArray = new InputFilter[2];
filterArray[0] = new InputFilter.AllCaps();
filterArray[1] = new InputFilter.LengthFilter(10);
wordText.setGravity(Gravity.CENTER);
Here's the layout file.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/match_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_marginTop="100dp">
<EditText android:id="@+id/word_text"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:hint="Your Word"
android:maxLength="15"
android:inputType="textCapWords"/>
<Button
android:id="@+id/match_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="start"
android:text="Match"
android:layout_marginTop="50dp"/>
</LinearLayout>
How can I add space between letters in API 12. I dont want to use setLetterSpacing().
Also, when I start typing, setGravity(Gravity.CENTER) is causing my letters to appear from the center of the box. How do i make it appear from Left to right ? If I set Gravity.LEFT, the EditText itself moves to the left in the LinearLayout. Can anyone help ?