椭圆选项的含义 [英] Meaning of the ellipsise options

查看:133
本文介绍了椭圆选项的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到 android:ellipsize 有4个不同的值:

I see that there are 4 different values to android:ellipsize:

无,开始,中,结束字幕

设置每一个的含义和作用是什么?

What is the meaning and effect of setting each of these?

推荐答案

请参见下图,了解 android:ellipsize 的工作方式

See the below image to know how android:ellipsize works

我使用了以下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>

这篇关于椭圆选项的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆