2

I have a couple of TextViews in my app, which should have exactly 3 lines. This works on Android 3+, but on Android 2.3, which I'd also like to support, these fields have exactly 2 lines. I've also tried TextView.setLines(3); in code, but that does not seem to help. This is my TextView:

<TextView
    d1p1:lines="3"
    d1p1:maxLines="3"
    d1p1:minLines="3"
    d1p1:ellipsize="end"
    d1p1:text="Some Text"
    d1p1:textAppearance="?android:attr/textAppearanceMedium"
    d1p1:layout_width="fill_parent"
    d1p1:layout_height="55dp"
    d1p1:id="@+id/detailsTextView"
    d1p1:layout_below="@+id/locationTextView"
    d1p1:textSize="13dp"
    d1p1:textColor="@color/app_darkgray"
    d1p1:background="@color/app_dark_background"
    d1p1:layout_marginLeft="@dimen/sr_horizontal_padding"
    d1p1:layout_marginRight="@dimen/sr_horizontal_padding" />

Setting the height to wrap_content also does not work.

huesforalice
  • 2,418
  • 2
  • 24
  • 29
  • 1
    Try setting height to wrap_parent and remove ellipsize. I am just taking a guess that ellipsize may be causing unintended behavior. – ian.shaun.thomas Oct 15 '12 at 17:52

1 Answers1

4

After some research it looks like my suspicion is correct. As discussed here (ellipsize multiline textview), Ellipsize causes issues with the min/max lines attributes. Because of this you may want to consider avoiding the Ellipsize otherwise, if that is not an option, you can follow the instructions in the other thread to use a custom TextView class to work around the problem.

Community
  • 1
  • 1
ian.shaun.thomas
  • 3,468
  • 25
  • 40
  • Great, this works. Really strange bug, thanks for finding this. Did not think that it had something to do with the ellipsizing. – huesforalice Oct 24 '12 at 10:16