andyPaul andyPaul - 14 days ago 5
Android Question

TextView Text clips

enter image description here

In the above image the gravity is set to right, don't know why the text slices out at the end.

TextView code is as shown below

<TextView
android:layout_width="fill_parent"
android:layout_height="50dp"
android:text="Month/Day/Year"
android:id="@+id/textView7"
android:onClick="onClickDateField"
android:clickable="true"
android:layout_toRightOf="@+id/textView6"
android:layout_below="@+id/genderRadioGroup"
android:gravity="center_vertical|right"
style="@style/FormFont"
android:inputType="text"
android:textSize="@dimen/form_date"
android:background="#ffffab5d" />


Style code is also listed below.

<style name="FormFont">
<item name="android:fontFamily">Roboto-Bold</item>
<item name="android:textStyle">italic|bold</item>
<item name="android:textColor">#009ACD</item>
</style>


Also, dimension is

<dimen name="form_date">35dp</dimen>

Answer

android:layout_width="fill_parent", gives you a rectangle for wrapped content rendering. All will work well for normal text (non-italic).

Once you have italic text enabled, the wrapped text will try to fit into the rectangle and hence the rightmost character will be cut off unless its un-cut-able.

Solution 1 :

you can add padding to TextView field like

android:paddingRight="3dp" 

Solution 2 :

you can add just extra space to the end of the text. If you add \u0020 to the end of the Text.