• 5
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to identify if a text was ellipsized or not

After a TextView being drawn on the screen, how to determine whether it was ellipsized or not?

TextView -> maxLines = 1 -> ellipsize = end

How to identify if a text was ellipsized or not? Using the texts below, should return true to text 1 and false to text 2.

String on screen

Lorem ipsum dolor sit amet, consectetuer adipiscing...

Sample text 1

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Sample text 2

Lorem ipsum dolor sit amet.

You can check

Layout layout = textview.getLayout();
if (layout != null) {
    int lines = layout.getLineCount();
    if (lines > 0) {
        if (layout.getEllipsisCount(lines-1) > 0) {
            return true;
        } else
            return false;
    }
}
  • 1
Reply Report
    • The only missing thing on this solution was that the layout is not prepared at the beginning so is necessary to call it inside the view post: textView.post { /** call logic here**/ }