Search code examples
androidtextview

TextView doesn't show full text


I have a TextView which works normally, but if I try to show text more than 500-600 symbols it doesn't show them, it just cuts them. Also is pushing down these 2 buttons and they are hiding and not visible. This is the xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="300dp"
    android:layout_height="0dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="5dp"
    android:layout_weight="13.07"
    android:background="@drawable/restaurants_buttons"
    android:orientation="vertical" >
    <TextView
       android:id="@+id/name"
       android:layout_width="280dp"
       android:layout_height="wrap_content"
       android:paddingBottom="10dp"
       android:paddingLeft="5dp"
       android:paddingTop="5dp"
       android:text="" />
    <TextView
        android:id="@+id/text"
        android:layout_width="280dp"
        android:layout_height="wrap_content"
        android:paddingBottom="10dp"
        android:paddingLeft="5dp"
        android:paddingTop="5dp"
        android:text="" />
    <TextView
        android:id="@+id/rest_id"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:paddingBottom="5dp"
        android:paddingTop="15dp" />


</LinearLayout>

<LinearLayout
    android:layout_width="300dp"
    android:layout_height="fill_parent"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="5dp"
    android:orientation="vertical" >

    <Button
        android:id="@+id/checkMenues"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/bg_button"
        android:gravity="center"
        android:padding="4dp"
        android:text="@string/checkMenues" />

    <Button
        android:id="@+id/makeReservation"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/bg_button"
        android:gravity="center"
        android:padding="4dp"
        android:text="@string/makeReservation" />
</LinearLayout>

</LinearLayout>

The problem textview is android:id="@+id/text"


Solution

  • You should wrap the linear layout in a scroll layout.

    Like this:

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="10dp">
    
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:minHeight="50dp"
            android:orientation="vertical" >
    
            <LinearLayout
                android:layout_width="300dp"
                android:layout_height="0dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="5dp"
                android:layout_weight="13.07"
                android:background="@drawable/restaurants_buttons"
                android:orientation="vertical" >
                <TextView
                    android:id="@+id/name"
                    android:layout_width="280dp"
                    android:layout_height="wrap_content"
                    android:paddingBottom="10dp"
                    android:paddingLeft="5dp"
                    android:paddingTop="5dp"
                    android:text="" />
                <TextView
                    android:id="@+id/text"
                    android:layout_width="280dp"
                    android:layout_height="wrap_content"
                    android:paddingBottom="10dp"
                    android:paddingLeft="5dp"
                    android:paddingTop="5dp"
                    android:text="" />
                <TextView
                    android:id="@+id/rest_id"
                    android:layout_width="300dp"
                    android:layout_height="wrap_content"
                    android:paddingBottom="5dp"
                    android:paddingTop="15dp" />
    
    
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="300dp"
                android:layout_height="fill_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="5dp"
                android:orientation="vertical" >
    
                <Button
                    android:id="@+id/checkMenues"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/bg_button"
                    android:gravity="center"
                    android:padding="4dp"
                    android:text="@string/checkMenues" />
    
                <Button
                    android:id="@+id/makeReservation"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/bg_button"
                    android:gravity="center"
                    android:padding="4dp"
                    android:text="@string/makeReservation" />
            </LinearLayout>
    
        </LinearLayout>
    
    </ScrollView>