TextInputLayout提示填充不起作用

Aks*_*125 3 android textinputlayout

我想给TextInputLayout中的edittext提示添加填充

电子邮件地址是提示,样本是文本

图片

也尝试了此解决方案,但没有用。

更改支持设计库23.1.0后面临此问题

这是我的代码

       <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp">

            <android.support.v7.widget.AppCompatEditText
                android:id="@+id/edtEmailAddress"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/border_round_edt_grey"
                android:focusableInTouchMode="true"
                android:hint="@string/emailadd"
                android:padding="10dp"
                android:singleLine="true" />
        </android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

pRa*_*NaY 6

按照这个答案,如果您在EditText上设置了自定义背景,则android:padding属性simple不能更改提示文本和编辑文本的间距。因此,如果您已将自定义背景设置为AppCompatEditText,则可以android:translationYAppCompatEditText中的use 属性

请在您的中添加以下行AppCompatEditText

android:translationY="10dp" 
Run Code Online (Sandbox Code Playgroud)

希望你能得到答案:)

  • 嗨,当我尝试android:translationY =“ 10dp”这些行时,它隐藏了底部的edittext边框如何解决? (2认同)