Android: how to determine the last fully visible email in TextView?

I am trying to create a book. And now I have a long text that fills the entire screen, and even part of the text goes beyond the screen. I want to know how to find the last letter that is fully displayed on the screen so that I can split the text into pages.

For example, all lines before

"Bad news, Vernon," she said ...

- fully visible text, and the remaining text should be moved to another page.

enter image description here

Like this (another page of text begins with "Bad News")

enter image description here

Here is the layout I used in the example above

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="...some text..." />
</RelativeLayout>
+4
source share
1

, , , /, , . Courier. , , , , , . , , , . , , .

ScrollView, TextView, . , :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="...some text..." />
    </ScrollView>
</RelativeLayout>

ScrollView, , , . , .

+1

Source: https://habr.com/ru/post/1679696/


All Articles