Textview does not show all the long text, no automatic line break

Asked

Viewed 23 times

2

Textview name does not show all text, name text is dynamic, I’ve tried to leave it with multiple lines but it didn’t work.

 <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="8dp"
        android:background="@color/white">
    
        <TextView
            android:id="@+id/tv_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toTopOf="@+id/tv_description"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <TextView
            android:id="@+id/tv_description"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            app:layout_constraintBottom_toTopOf="@+id/tv_address"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv_name" />
    
        <TextView
            android:id="@+id/tv_address"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:visibility="gone"
            android:ellipsize="none"
            android:scrollHorizontally="false"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv_description" />
    
    
    </androidx.constraintlayout.widget.ConstraintLayout>

enter image description here

  • The two one, I can’t remember now, or the component TextView has an attribute to leave with more than one line that can be configured in XML itself or programmatically and you will need to go after which is (and also how to separate the lines, if with \n, HTML tags or otherwise), or there is some other component more suitable than TextView for the situation of texts with multiple lines (perhaps one is specialization of the other).

  • The problem is that the text is dynamic, so I have to go and add n. I’m still having the problem. I couldn’t solve @Piovezan

  • 1

    I don’t know how to help anymore, I haven’t touched Android in a while. I’ll give a question and leave it there to see if someone answers. Maybe the wrap_content in relation to the length has some relation, maybe the ellipsize should be None, I do not know.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.