有没有一种方法来检查,如果一个TextView的文本被截断 [英] Is there a way to check if a TextView's text is truncated

查看:258
本文介绍了有没有一种方法来检查,如果一个TextView的文本被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来检查一个TextView的文本是在我的code截断?

Is there a way to check whether a TextView's text is truncated in my code?

推荐答案

您可以使用方法:getEllipsisCount

You can use method: getEllipsisCount

 public static boolean isTextTruncated( String text, TextView textView )
    {
        if ( textView != null && text != null )
        {

            Layout layout = textView.getLayout();
            if ( layout != null )
            {
                int lines = layout.getLineCount();
                if ( lines > 0 )
                {
                    int ellipsisCount = layout.getEllipsisCount( lines - 1 );
                    if ( ellipsisCount > 0 )
                    {
                        return true;
                    }
                }
            }

        }
        return false;
    }

我发现下面的相关职位的答案是:

I found the answer at the following related post:

检查TextView的是Android ellipsized

Check if textview is ellipsized in android

这篇关于有没有一种方法来检查,如果一个TextView的文本被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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