My program reads data from a file and displays it in a TextView . I need to determine the number of virtual pages into which the text of the file is divided. The height / width of one page = height / width of the entire screen. Algorithm, how to calculate, I developed. Here is the code:
countOfLines = (text.getHeight() / text.getLineHeight()); pages = Math.round(text.getLineCount() / countOfLines) + 1; pagesView.setText(currentPage + "/" + pages); text - TextView with text. countOfLines - number of pages. pagesView - TextView which displays the number of pages.
So, the problem is, I need to determine the number of pages immediately after the content is displayed, but when I try to execute this code in any of the lifecycle methods, text.getHeight() always returns 0. But outside the lifecycle methods, the application returns the correct value . So how should I be?