Reputation: 227
Anyone know why this isn't wrapping content properly? Something to do with the gradient and the way the label_view is constrained is causing it to match parent somehow?
thanks
<ImageView
android:id="@+id/gradient"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/hero_gradient"
app:layout_constraintTop_toTopOf="@id/gradient_guide"
app:layout_constraintBottom_toBottomOf="@id/image_view"
android:contentDescription="@null"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/left_margin"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_begin="8dp"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/right_margin"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_end="8dp"/>
<TextView
android:layout_marginTop="50dp"
android:id="@+id/label_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="12sp"
android:gravity="center"
tools:text="TEST TEXT"
android:textColor="@color/pink"
app:layout_constraintTop_toBottomOf="@id/gradient"
app:layout_constraintBottom_toTopOf="@+id/gradient"
app:layout_constraintStart_toStartOf="@id/left_margin"
app:layout_constraintEnd_toEndOf="@id/right_margin"
android:paddingBottom="4dp"/>
Thats just a snippet of the offending parties.
Upvotes: 0
Views: 178
Reputation: 227
I must really be having a slow day. I was backwardly setting the centre.
I was doing
app:layout_constraintTop_toBottomOf="@id/gradient"
app:layout_constraintBottom_toTopOf="@+id/gradient"
But I should be doing
app:layout_constraintTop_toTopOf="@id/gradient"
app:layout_constraintBottom_toBottomOf="@id/gradient"
Upvotes: 0