Android Textview Italic and wrap_contents
Asked Answered
I

3

10

I am using 3 italic textviews with different colors

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:orientation="horizontal" android:id="@+id/submittedBy" android:paddingTop="10dip">


            <ImageView android:id="@+id/subByImg"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:gravity="left" android:layout_gravity="bottom" android:src="@drawable/submitted_by_arrow"/>
            <TextView android:id="@+id/submitLabel"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:gravity="left" android:text="Submitted by"  android:textStyle="italic"
                android:textSize="12sp" android:textColor="@color/gray" android:paddingLeft="5dip"/>
            <TextView android:id="@+id/submitName" android:textStyle="italic"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:textSize="12sp" android:textColor="@color/maroon_dark" android:paddingLeft="10dip"/>
                <TextView android:id="@+id/submitByDate" android:textStyle="italic"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:gravity="left"
                android:textSize="12sp" android:textColor="@color/gray" android:paddingLeft="10dip"/>
            </LinearLayout>

I wonder every last character is not displaying properly specially name displayed in the middle is "Dan Buckland" and it it is missing last character looks like "Dan Bucklano"

Also tell me pls how can have textview italic and bold both..

alt text http://www.freeimagehosting.net/uploads/953d573113.jpg

Iota answered 16/2, 2010 at 6:55 Comment(0)
C
2

Seems like the bounding box is not correctly calculated when using italic.

Have you tried to use paddingLeft=6 and paddingRight=6 for the elements? (less chance of overlap).

For multiple styles in a TextView see Is it possible to have multiple styles inside a TextView?

Cecelia answered 16/2, 2010 at 8:53 Comment(0)
L
7

I had the exact same problem. I got around it by simply adding a space to the end of any string that needs to be in italics.

It may not be the most long-term-correct solution but it worked for me.

Lamarlamarck answered 9/5, 2010 at 20:41 Comment(2)
Yes, that works. Use one extra space or have "fill_parent" as width. Shame this is not handled correctly by Android (mine is 2.3.7).Siobhan
You'll have to use \u0020 to force a space if you're using XML.Brazell
C
2

Seems like the bounding box is not correctly calculated when using italic.

Have you tried to use paddingLeft=6 and paddingRight=6 for the elements? (less chance of overlap).

For multiple styles in a TextView see Is it possible to have multiple styles inside a TextView?

Cecelia answered 16/2, 2010 at 8:53 Comment(0)
H
1

You can use &#160; with the text in string.xml file.

Hulburt answered 1/4, 2014 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.