3

In my layout, the last view (Blue Text) is getting cropped like shown in the image below.

enter image description here

I have my ConstraintLayout setup like follows

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">

   <ImageView
        android:id="@+id/ivIcon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="10dp"
        android:background="@color/blue"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <TextView
        android:id="@+id/tvMain"
        style="@style/ActorTextMainOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginTop="28dp"
        android:text="28"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <TextView
        android:id="@+id/tvSecondaryOne"
        style="@style/ActorTextSecondary"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="4dp"
        android:text="Jun"
        app:layout_constraintBottom_toTopOf="@+id/tvSecondaryTwo"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/tvMain"/>

    <TextView
        android:id="@+id/tvSecondaryTwo"
        style="@style/ActorTextSecondary"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="4dp"
        android:text="2017"
        app:layout_constraintBottom_toBottomOf="@+id/tvMain"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/tvMain"/>

    <TextView
        android:id="@+id/tvDescription"
        style="@style/ActorTextDescription"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="4dp"
        android:text="@string/arrival_date"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@+id/tvMain"
        app:layout_constraintTop_toBottomOf="@+id/tvSecondaryTwo"/>

</android.support.constraint.ConstraintLayout>

ConstraintLayout version being used is 1.0.2

I think I am missing something obvious here but I am unable to figure it out. How can I make the blue text at the bottom fully visible while keeping the ConstraintLayout's height to wrap_content?

Much Overflow
  • 3,142
  • 1
  • 23
  • 40

1 Answers1

1

Try Changing

app:layout_constraintTop_toBottomOf="@+id/tvSecondaryTwo"

to

app:layout_constraintTop_toBottomOf="@+id/tvMain"

for textview with id tvDescription

This makes the textview with id tvDescription to be below the textview with id tvMain.

Raghunandan
  • 132,755
  • 26
  • 225
  • 256
  • This indeed shows the entire blue text. However, it was constrained against tvSecondaryTwo to overcome additional bottom space caused by tvMain. Sorry, I did not mention this in my original question. Could you please explain why it is not working when constrained against tvSecondaryTwo? – Much Overflow Dec 17 '17 at 10:29
  • i din't understand "additional space caused by tvMain"? – Raghunandan Dec 17 '17 at 10:31
  • The large textview caused additional top and bottom padding. Same issue as the one asked here https://stackoverflow.com/questions/6593885/how-to-remove-the-top-and-bottom-space-on-textview-of-android – Much Overflow Dec 17 '17 at 10:34
  • the textview is wrap_content. However if you increase the textsize you will see that space. The text view has no text padding as seen in the xml. you can try the solutions in the link you posted. i have no tried any of the solutions mentioned there. – Raghunandan Dec 17 '17 at 10:40
  • @MuchOverflow you can look at how it looks if you use tvSecondaryTwo instead https://imgur.com/8xj9SOU. The textMain cuts of your tvDescription. The space issue is not related to constraintlayout bu the textview and its size – Raghunandan Dec 17 '17 at 10:48
  • Thank you very much. Appreciate your help! – Much Overflow Dec 17 '17 at 11:03