Issue
I'm facing this problem for the first time, my text overlap the button, i tried using barrier,guidelines but get text on center of button and start parent. I'm achieving the textViews text will be start on parent and end on before button and button always stay on end of parent like below picture.
My layout.
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/titleTextView"
android:text="title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleTextView"
android:id="@+id/descriptionTextView"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/copyImageView"
android:tint="?android:textColorSecondary"
android:src="@drawable/ic_content_copy_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Solution
You have to set the width to 0dp which means match_constraint and also constraint its end to the start of ImageView
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/titleTextView"
android:text="title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleTextView"
android:id="@+id/descriptionTextView"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
app:layout_constraintEnd_toStartOf="@id/copyImageView"
android:layout_width="0dp"
android:layout_height="0dp"/>
<ImageView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/copyImageView"
android:tint="?android:textColorSecondary"
android:src="@drawable/ic_content_copy_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Answered By - svkaka
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.