0

I'm having trouble displaying some text in a dialog. When the user has forgotten their password, I use the "forgot password" TextView to display a message explaining what happens when they put their email address in. The layout for this is:

<TextView
    android:id="@+id/forgotpasswordtextview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/forgotpassword"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/md_text_yellow"
    android:gravity="right" />

It's inside a <LinearLayout></LinearLayout> with the following properties:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/base_panel"
    android:orientation="vertical"
    android:padding="6dip" >

It starts as a one-line view and expands to a four-line view.

Within the dialog constructor, I have a layout instruction:

    mParent = LayoutInflater.from(context).inflate(R.layout.login, null);

    setContentView(mParent, new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

I changed this to have the dialog height be 600 (it worked—one vertically stretched dialog) and the TextView is STILL only displaying four lines, so it's not being crushed by its parent.

What could be causing this?

EDIT:

Changing the TextView to android:textAppearance="?android:attr/textAppearanceSmall" cuts the string off at the same point, displaying three lines. I am now wondering if this is a string problem and not a TextView problem.

The original string is:

Please enter your registered email and we will send you details of how to reset your password. If you do not know your email then please contact us.

And it cuts off at:

Please enter your registered email and we will send you details of how to reset your password. If you do not

with small text (three lines) and

Please enter your registered email and we will send you details of how to reset your password. If you do not know

with medium text (four lines).

A new test string I put in is:

0________ 1________ 2________ 3________ 4________ 5________ 6________ 7________ 8________ 9________ 10_______ 11_______ 12_______ 13_______ 14_______ 15_______ 16_______ 17_______

And it cuts off at:

0________ 1________ 2________ 3________ 4________ 5________ 6________ 7________ 8________ 9________ 10_______ 11_______ 12_______ 13_______ 14_______

with small text (five lines) and

0________ 1________ 2________ 3________ 4________ 5________ 6________ 7________ 8________ 9________ 10_______ 11_______

with medium text (six lines).

FURTHER EDIT:

Shortening the string suggests it is cutting off the last line or two. Could be like Android: Last line of textview cut off. Adding a newline to the string file gives me another line, but not the whole string!

Community
  • 1
  • 1
Andrew Wyld
  • 7,133
  • 7
  • 54
  • 96

1 Answers1

3

Try to use the following attributes for your text view

android:maxLines="10"

android:ellipsize="none"

android:singleLine="false"

nheimann1
  • 2,348
  • 2
  • 21
  • 33
  • I've tried the first two but not singleLine (though the fact that it's displaying more than one line is a bit weird). I shall try it though! – Andrew Wyld Dec 14 '12 at 14:33
  • No effect at all, I'm afraid. – Andrew Wyld Dec 14 '12 at 14:34
  • Try to test this text view outside of the dialog. Write a simple activity that shows this text view. Does it have the same results. If yes publish here the whole program with the simple activity, and people would be able to test it themselves. If no, the problem is related to something else, but at least you would know that there is no point in investigating the text view. – nheimann1 Dec 14 '12 at 16:39
  • Hurray!, this atleast fixed my problem :D. Apparently having `android:ellipsize="end"` only works on ICS or higher and messes up on e.g. GB (I specified 4 lines, it cut off somewhere on the 2nd line, which didn't happen on ICS). – Joep_H Jan 08 '13 at 11:16
  • `android:singleLine` is now deprecated – Gene Bo Oct 28 '16 at 03:19