Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9150163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:34:34+00:00 2026-06-17T11:34:34+00:00

I have a strange behaviour when using bold text in an textview. So the

  • 0

I have a strange behaviour when using bold text in an textview.

So the problem is as follows, I have created a custom item which holds text and is supposed to be used as an item later on in a list, so the item is contained several times in a scrollviews linearlayout, which has vertical orientation.

the item layout is as follows

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    style="@style/ButtonItem">
    <TextView
        android:id="@+id/m_oItem_TextView_TopLeft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="20dp"
        android:layout_alignParentTop="true"
        android:layout_marginTop="10dp"
        android:textColor="@color/black"
        android:textSize="@dimen/font_size_12" />
    <TextView
        android:id="@+id/m_oItem_TextView_TopMiddle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/m_oItem_TextView_TopLeft"
        android:layout_toRightOf="@+id/m_oItem_TextView_TopLeft"
        android:layout_toLeftOf="@+id/m_oItem_TextView_TopRight"
        android:layout_marginRight="20dp"
        android:textColor="@color/black"
        android:textSize="@dimen/font_size_12"
        android:gravity="right"/>
    <TextView
        android:id="@+id/m_oItem_TextView_TopRight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="40dp"
        android:layout_alignTop="@+id/m_oItem_TextView_TopLeft"
        android:textColor="@color/black"
        android:textSize="@dimen/font_size_12"/>
    <TextView
        android:id="@+id/m_oItem_TextView_Bottom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/m_oItem_TextView_TopLeft"
        android:layout_alignRight="@+id/m_oItem_TextView_TopRight"
        android:layout_below="@+id/m_oItem_TextView_TopLeft"
        android:layout_marginTop="5dp"
        android:textColor="@color/black"
        android:textSize="@dimen/font_size_14" />
    <ImageView 
        android:id="@+id/m_oItem_PlaceHolder"
        android:layout_width="wrap_content"
        android:layout_height="10dp"
        android:layout_alignLeft="@+id/m_oItem_TextView_TopLeft"
        android:layout_alignRight="@+id/m_oItem_TextView_TopRight"
        android:layout_below="@+id/m_oItem_TextView_Bottom"
        android:contentDescription="@string/image_description"/>
    <ImageView
        android:id="@+id/m_oPart_Arrow_Image"
        android:scaleType="fitCenter"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true" 
        android:layout_marginRight="5dp"
        android:src="@drawable/arrow_right"
        android:contentDescription="@string/image_description"/>
</RelativeLayout>

the m_oItem_TextView_Bottom textview is the part that will contain text that may be too long for it, thus increasing the height of the textview if needed. As I tested this, all was working correct and the textview had the needed height.

however once I set

android:textStyle="bold"

the text will of course become wider, thus may need more lines. The problem now is that this will not be accounted by android somehow.

e.g. if the non bold line barely requires two lines like (last item in the image below)

last item with two lines

the bold text will require three lines, but the textview will still only provide two lines

last item with three lines

Did anyone ever run into the same problem or has a solution or at least a suggestion how I could resolve the issue. Thanks in advance in any case

EDIT:
as requested the ButtonItem style is this

<style name="ButtonItem">
    <item name="android:background">@drawable/button_item</item>
</style>

@drawable/button_item being:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"  android:drawable="@drawable/button_item_down" />
    <item android:state_selected="true"  android:drawable="@drawable/button_item_selected" />
    <item android:drawable="@drawable/button_item_normal" />
</selector>

@drawable/button_item_down being:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:bottom="1dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/white" />
            <stroke
                android:width="@dimen/button_item_stroke_thickness"
                android:color="@color/black"/>
        </shape>
    </item>
</layer-list>

@drawable/button_item_selected being:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:bottom="1dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/white" />
            <stroke
                android:width="@dimen/button_item_stroke_thickness"
                android:color="@color/black"/>
        </shape>
    </item>
</layer-list>

@drawable/button_item_normal being:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:bottom="1dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape android:shape="rectangle" >
            <solid android:color="@color/transparent" />
            <stroke
                android:width="@dimen/button_item_stroke_thickness"
                android:color="@color/black" />
        </shape>
    </item>
</layer-list>

essentially they are just there to create the black line beneath the item and make the background white if it is clicked or selected. although the selected on is never used since the selected state is never set in code anyway.

I also tried it without the style as the background, but as expected the issue remained the same.

EDIT AGAIN:
Okay so I was able to track down the problem some more, the resizing of the textview is actually correct. the concrete problem is if following. If the last word of a line (e.g “this is a test” while test being the last word) causes a line break, the last word needs to be long enough somehow. I testes this using dummy strings, with the same item used in the question.

here are some pics
enter image description here

As you can see the line that causes the issue needs one more character then the word is long enough to fit in.

LAST EDIT:
okay found the answer (see below)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:34:35+00:00Added an answer on June 17, 2026 at 11:34 am

    FINALLY I TRACKED DOWN THE ISSUE,

    So here is the solution, the problem was the margin_Right of the m_oItem_TextViewBottom which was caused by:

    android:layout_alignRight="@+id/m_oItem_TextView_TopRight"
    

    thus it effectivly created a margin right which was the troublemaker, I tested this with other textviews and right margins and they all had the same issue.

    I replaced it with a Padding of the same margin and ended up with this as my final solution for the item.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        style="@style/ButtonItem">
        <TextView
            android:id="@+id/m_oItem_TextView_TopLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="20dp"
            android:layout_alignParentTop="true"
            android:layout_marginTop="10dp"
            android:textColor="@color/black"
            android:textSize="@dimen/font_size_12" />
        <TextView
            android:id="@+id/m_oItem_TextView_TopMiddle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/m_oItem_TextView_TopLeft"
            android:layout_toRightOf="@+id/m_oItem_TextView_TopLeft"
            android:layout_toLeftOf="@+id/m_oItem_TextView_TopRight"
            android:layout_marginRight="20dp"
            android:textColor="@color/black"
            android:textSize="@dimen/font_size_12"
            android:gravity="right"/>
        <TextView
            android:id="@+id/m_oItem_TextView_TopRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:paddingRight="40dp"
            android:layout_alignTop="@+id/m_oItem_TextView_TopLeft"
            android:textColor="@color/black"
            android:textSize="@dimen/font_size_12"/>
        <TextView
            android:id="@+id/m_oItem_TextView_Bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/m_oItem_TextView_TopLeft"
            android:layout_below="@+id/m_oItem_TextView_TopLeft"
            android:layout_marginTop="5dp"
            android:paddingRight="40dp"
            android:textColor="@color/black"
            android:textStyle="bold" />
        <ImageView 
            android:id="@+id/m_oItem_PlaceHolder"
            android:layout_width="wrap_content"
            android:layout_height="10dp"
            android:layout_alignLeft="@+id/m_oItem_TextView_TopLeft"
            android:layout_alignRight="@+id/m_oItem_TextView_TopRight"
            android:layout_below="@+id/m_oItem_TextView_Bottom"
            android:contentDescription="@string/image_description"/>
        <ImageView
            android:id="@+id/m_oPart_Arrow_Image"
            android:scaleType="fitCenter"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true" 
            android:layout_marginRight="5dp"
            android:src="@drawable/arrow_right"
            android:contentDescription="@string/image_description"/>
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange behaviour. I am using a rather heavy page (4000 nodes)
I am noticing strange behaviour when using the split() method in Java. I have
I have noticed a strange piece of behaviour when using MessageDlg and attempting to
I have a strange behaviour going on. I am using Seam and JBPM. When
I'm using hibernate 3.6.1 and i have a strange behaviour on the sql generated
I'm getting some strange behaviour with my form (using Zend Form). I have a
I've just ran into a pretty strange behaviour of multiline text in firefox using
I have encountered a strange behaviour using dijit.form.select inside a tooltip-dialog. Here's a shortened
I have strange problem. For a project we are using following cloud hosting. http://www.rackspace.com
I have noticed a strange behaviour when using the command functionality in Silverlight: When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.