Значение опций многоточия

Я вижу, что для android:ellipsize есть 4 разных значения:

нет, начало, середина, конец и выделение

Каков смысл и эффект установки каждого из них?


person png    schedule 05.01.2012    source источник
comment
stackoverflow.com/questions/2160619/   -  person Padma Kumar    schedule 05.01.2012


Ответы (1)


Посмотрите на изображение ниже, чтобы узнать, как работает android:ellipsize введите описание изображения здесь

Я использовал следующий 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>
person Sunil Kumar Sahoo    schedule 05.01.2012
comment
невозможно объяснить лучше ... так что выделение и конец имеют одинаковый эффект. Я использовал в своем текстовом представлении бегущую строку, и она не появлялась на устройстве, и я просто пробовал тестировать с концом и его приходом. Любой комментарий к этому поведению. Большое спасибо. - person png; 05.01.2012
comment
Вы устанавливаете android:maxLines="4", а TextViews имеют 2 строки. Почему? - person jul; 02.04.2012
comment
Размер среднего и начального эллипса не работает для Honeycomb и более поздних версий Android. - person Mike; 31.03.2014
comment
@Mike, это не обязательно правда (по крайней мере, на Nexus 5 под управлением Android L в январе 2016 года) - person Richard Le Mesurier; 08.01.2016
comment
для случая @png нужно установить singleLine=true. интересно, когда вы комбинируете ellipsize=marquee и singleLine=true, вы не получаете предупреждение об устаревании. - person Aba; 14.08.2018