mithrop
mithrop

Reputation: 3363

ellipsize disable initial text

I have a strange behavior with the use of singleLine=true and ellipsize=start with a Button.

First of all, the declaration of my button :

<Button
    android:id="@+id/enterDeparture"
    android:layout_width="175dp"
    android:layout_height="30dp"
    android:layout_marginLeft="10dp"
    android:background="@drawable/field_button"
    android:text="@string/research_enterDeparture"
    android:textColor="@drawable/field_button_textcolor"
    android:paddingLeft="3dp"
    android:paddingRight="3dp"
    android:ellipsize="start"
    android:singleLine="true" />

With this declaration, no text is displayed inside the button. But if I write Log.d(TAG, "the text is : " + findViewById(R.id.enterDeparture));, the LogCat gives me the correct value...

I tried to set the text programatically, either in the onCreateView() and in the onResume() methods : same behavior. But if I set the text really later of if I put an AlertDialog over my screen, the content come back immediatly...

To finish, if I remove the two lines android:ellipsize="start" and android:singleLine="true", everything is normal : my text is displayed in the first time.

EDIT

I tried to remove the singleLine=true line : the initial content is actually displayed but the ellipsize behavior doesn't work anymore...

So I tried with maxLines=1 : the initial content is displayed, but the "..." are not shown anymore (the content is just truncated).

Upvotes: 0

Views: 204

Answers (1)

Graeme
Graeme

Reputation: 25864

Try changing the height value:

android:layout_height="wrap_content"

You could be elipsising your text to ... and because the button padding it could be being hidden.

Also you want to try this instead:

Log.d(TAG, "the text is : " + ((Button)findViewById(R.id.enterDeparture)).getText())

Upvotes: 1

Related Questions