1

我想在 textview 之前放置两个 Imageview。当 textview 是单行时,我得到所需的输出,见下文

单行文本视图

如果 textview 是多行的,则会添加额外的空间,我不知道如何修复它。这是图像和代码

需要修复的多行文本视图

<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>

4

1 回答 1

0

我可以找到一个可以完全删除所有填充的答案TextView,但最终在通过官方文档后,解决了单行文本。

java File这将是:

setIncludeFontPadding(false)

XML这将是:

android:includeFontPadding="false"
android:lineSpacingExtra="0dp"
于 2021-10-06T04:54:49.847 回答