Text does not ellipsize

前端 未结 13 1426
隐瞒了意图╮
隐瞒了意图╮ 2020-12-25 11:43

I have a TextView set to ellipsize but when I put the text in it doesn\'t do so. Any ideas?



        
13条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-25 12:24

    You need to match the settings for android can correctly calculate the position of the object. Has several possible combinations, and depends on the rest of the layout is on the same line.

    This is a combination that works:

    android:layout_width="0dip" // dynamic width
    android:layout_weight="1"   // less weight, other objects still "0"
    android:ellipsize="end"     // ... into end of text (right)
    android:singleLine="true"   // one line, deprecated, but necessary for some ambients
    android:maxLines="1"        // one line, new mode
    

    In summary, you indicate the weight, if you use dynamic layout, or just a fixed size, then indicates to only have one line and configures how "..." is displayed.

提交回复
热议问题