【问题标题】:TextInputLayout hint padding not workingTextInputLayout 提示填充不起作用
【发布时间】:2015-10-19 14:51:03
【问题描述】:

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

其中电子邮件地址是提示,示例是文本

也试过this solution,但没用。

在更改支持设计库 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>

【问题讨论】:

    标签: android textinputlayout


    【解决方案1】:

    根据this 回答,如果您在 EditText 上设置了自定义背景,则 android:padding 属性 simple 无法更改提示文本和编辑文本的间距。所以如果您为 AppCompatEditText 设置了自定义背景,则可以在 AppCompatEditText 中使用android:translationY 属性

    请在您的AppCompatEditText 中添加以下行。

    android:translationY="10dp" 
    

    希望你得到你的答案:)

    【讨论】:

    • 感谢它的工作。!!与android:translationY="2dp"
    • 嗨,当我尝试 android:translationY="10dp" 这些行时,它隐藏了底部的edittext边框如何解决?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 2018-01-19
    • 2012-08-02
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多