简体   繁体   English

TextInputLayout - 提示填充问题

[英]TextInputLayout - Hint padding issue

I am using textInputLayout in my application, but I am getting additional padding to the Hint.我在我的应用程序中使用 textInputLayout,但我得到了对提示的额外填充。 Can anyone help me out.谁能帮我吗。

Screenshot:截屏: 在此处输入图像描述

Xml Code: Xml 代码:

<com.google.android.material.textfield.TextInputLayout
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
            android:id="@+id/outlined_member_name_text_field"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="16dp"
            android:hint="@string/name"
            app:startIconDrawable="@drawable/ic_baseline_person_24"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/select_contact_button">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/member_name_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textCapSentences|text" />

        </com.google.android.material.textfield.TextInputLayout>

You can add -ve padding to TextInputEditText, it should solve the extra padding issue that you have.您可以将 -ve 填充添加到 TextInputEditText,它应该可以解决您遇到的额外填充问题。 For example I have used -10dp you can check what fits your case.例如,我使用了 -10dp,您可以检查适合您的情况。

  <com.google.android.material.textfield.TextInputLayout       
  style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:id="@+id/outlined_member_name_text_field"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="16dp"
        android:hint="@string/name"
        app:startIconDrawable="@drawable/ic_baseline_person_24"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/select_contact_button">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/member_name_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawablePadding="-10dp"
            android:inputType="textCapSentences|text" />

    </com.google.android.material.textfield.TextInputLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM