2012-01-05 15 views
16

ho visto possiamo impostare 4 valori per android:ellipsize quali:Android: Ellipsise, significato delle opzioni

nessuno, avviare, a metà, fine e tendone

Qual è il significato e l'effetto di impostare ciascuno di questi?

+0

http://stackoverflow.com/questions/2160619/android-ellipsize-multiline-textview –

risposta

29

vedere l'immagine qui sotto per sapere come funziona android:ellipsize enter image description here

ho usato XML seguente

<?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

non può essere spiegato meglio .. quindi tendone e fine ha lo stesso effetto. Stavo usando nel mio riquadro di selezione di testo e non veniva sul dispositivo e ho appena provato a testare e alla fine. Qualsiasi commento su questo comportamento. Grazie mille – png

+9

Hai impostato 'android: maxLines =" 4 "', e TextViews hanno 2 righe. Perché? – jul

+0

great post thx! –

Problemi correlati