'How to stop long text in textview overlapping an image on left constraint

I have a image and a textview next to it in a constraint layout, textview has a really long text and I want fit the text within the text view and not overlap on the image

this is what I have tried

enter image description here

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/tariffTileHeader"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

        <androidx.appcompat.widget.AppCompatImageView
            android:id="@+id/tariffIconIV"
            android:layout_width="36dp"
            android:layout_height="36dp"
            android:layout_marginTop="4dp"
            android:src="@drawable/ic_electricity_circle_logo"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/tariffDescTV"
            style="@style/Text.Large.Bold"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:lines="3"
            app:layout_constraintStart_toEndOf="@+id/tariffIconIV"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:text="This is a very long name to be sue it fits no matter how long it is" />

    </androidx.constraintlayout.widget.ConstraintLayout>

This is how it looks

could you suggest what I am missing here please

thanks for your suggestions R



Solution 1:[1]

You can use this code to set up the text in the layout.

<androidx.constraintlayout.widget.ConstraintLayout 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"
    android:gravity="center"
    android:orientation="vertical">

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/tariffIconIV"
        android:layout_width="0dp"
        android:layout_height="36dp"
        android:layout_marginTop="4dp"
        android:src="@drawable/ic_launcher_background"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/tariffDescTV"
        style="@style/Text.Large.Bold"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:lines="3"
        app:layout_constraintStart_toEndOf="@+id/tariffIconIV"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="This is a very long name to be sue it fits no matter how long it is" />


</androidx.constraintlayout.widget.ConstraintLayout>

Here is the desired output.

Desired output

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JAY_Panchal