1

I would like to place two Imageviews before a textview. When the textview is single line then I am getting the desired output see below

Singline textview

If the textview is multiline then extra space is added and I am not sure how to fix it. Here is the image and code

Multiline textview which needs to get fixed

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white">

    <androidx.appcompat.widget.LinearLayoutCompat
            android:id="@+id/title_holder"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/dp16"
            android:layout_marginTop="@dimen/dp18"
            android:layout_marginEnd="@dimen/dp16"
            android:orientation="horizontal"
            app:layout_constrainedWidth="true"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

        <ImageView
                android:id="@+id/som_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginEnd="@dimen/dp8"
                android:src="@drawable/ic_info_icon"
                app:layout_constraintBottom_toBottomOf="@id/name_details"
                app:layout_constraintEnd_toStartOf="@id/name_details" />
        <ImageView
                android:id="@+id/hand_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginEnd="@dimen/dp8"
                android:src="@drawable/ic_hand"
                app:layout_constraintBottom_toBottomOf="@id/name_details"
                app:layout_constraintEnd_toStartOf="@id/name_details" />

        <TextView
                android:id="@+id/name_details"
                style="@style/sharp_sans_semi_bold_20"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAlignment="center"
                tools:text="Mynameis RachelKaren " />
    </androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>

Zain
  • 37,492
  • 7
  • 60
  • 84
falcon2403
  • 33
  • 4
  • 2
    When I copy & paste your code into an empty project it shows the desired behavior (except that I replaced `@dimen/dpX` by `Xdp` and removed the style tag of the text view, as I don't have those values). – GenError Oct 05 '21 at 17:25

0 Answers0