Search code examples
androidxmltextviewscrollviewandroid-linearlayout

TextView doesn't show full content


My xml layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TestingActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        <TextView
            android:id="@+id/pt_results"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/blank"/>
        <Button
            android:id="@+id/get_po_results"
            android:onClick="onGetPOResultsClick"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/blank"/>
        </LinearLayout>
    </ScrollView>
</android.support.v7.widget.LinearLayoutCompat>

I set TextView's text by simple setText on xml type resource. Here is this resource:

<string name="r0010">code:0010 \n \n \n \n There will be a lot of text. It must separate lines automatically using spaces between lines.
    Showing what ScrollView capable of: \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n That's a lot of lines</string>

I'd like to see something like:

code:0010

[some empty lines]

There will be a lot of text. It must separate lines automatically using spaces between lines






[a lot of empty lines]







That's a lot of lines

But here is what i get: (phone screenshot 1) and (phone screenshot 2) (TextView cut end of the text)

My first guess was that it's all because of the limited TextView capacity but I didn't find anything about it.

Btw, I saw this question (it's almost similar to mine) but it's not my case as I wrapped LinearLayout into ScrollView

The thing is, I need to display a huge amount of text. Maybe TextView is not the tool I need? What alternatives does TextView have?


Solution

  • try using the below string,from your code it output it seems your text is not read after ' character so i just changed.

    that's
    

    with

    that\'s
    

    try the below string

    <string name="r0010">code:0010 \n \n \n \n There will be a lot of text. It must separate lines automatically using spaces between lines.
    Showing what ScrollView capable of: \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n That\'s a lot of lines</string>
    

    try logging the string to see if it is really your TextView that is cropping the text or the string passed to TextView is cropped itself that will explain you the problem