2012-01-05 61 views
16

我看到我們可以設置4個值來android:ellipsize如選項的含義:安卓:Ellipsise的

沒有,啓動,中旬,結束選取框

什麼意義和作用設置每個這些?

+0

http://stackoverflow.com/questions/2160619/android-ellipsize-multiline-textview – 2012-01-05 09:00:40

回答

29

見下面的圖片就知道如何android:ellipsize工作 enter image description here

我用下面的XML

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:maxLines="4" 
android:ellipsize="none" 
android:singleLine="false" 
android:text="Hi make this a very long string that wraps at least 4 lines, seriously make it really really long so it gets cut off at the fourth line not joke. Just do it!" 
android:layout_marginBottom="25dip" 
/> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:maxLines="4" 
android:ellipsize="start" 
android:singleLine="false" 
android:text="Hi make this a very long string that wraps at least 4 lines, seriously make it really really long so it gets cut off at the fourth line not joke. Just do it!" 
android:layout_marginBottom="25dip"/> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:maxLines="4" 
android:ellipsize="middle" 
android:singleLine="false" 
android:text="Hi make this a very long string that wraps at least 4 lines, seriously make it really really long so it gets cut off at the fourth line not joke. Just do it!" 
android:layout_marginBottom="25dip"/> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:maxLines="4" 
android:ellipsize="end" 
android:singleLine="false" 
android:text="Hi make this a very long string that wraps at least 4 lines, seriously make it really really long so it gets cut off at the fourth line not joke. Just do it!" 
android:layout_marginBottom="25dip"/> 


<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:maxLines="4" 
android:ellipsize="marquee" 
android:text="Hi make this a very long string that wraps at least 4 lines, seriously make it really really long so it gets cut off at the fourth line not joke. Just do it!" /> 

</LinearLayout> 
+0

不能更好地解釋..所以選取框和結束有相同的效果。我在我的textview字幕中使用,它不是在設備上來,只是試圖結束和未來的測試。對此行爲有任何評論。非常感謝您 – png 2012-01-05 09:45:12

+9

您設置了'android:maxLines =「4」',TextViews有2行。爲什麼? – jul 2012-04-02 12:42:50

+0

偉大的帖子thx! – 2012-10-25 16:07:30