【问题标题】:TextInputLayout hint is too highTextInputLayout 提示太高
【发布时间】:2017-01-13 01:36:33
【问题描述】:

当您单击 eddittext 时,有什么方法可以为提示添加填充? 我尝试在 edittext 和 TextInputLayout 中添加填充和边距。

目前:

  <android.support.design.widget.TextInputLayout
            android:id="@+id/login_layout_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="12dp"
            android:layout_marginEnd="36dp"
            android:layout_marginStart="36dp"
            android:background="@color/color_line_transparent"
            android:gravity="center"
            android:paddingEnd="16dp"
            android:paddingStart="16dp"
            android:theme="@style/TextLabel"
            app:errorTextAppearance="@style/TextAppearance.Design.Error">

            <EditText
                android:id="@+id/login_input_email"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:hint="@string/hint_email"
                android:inputType="textEmailAddress"
                android:textColor="@color/color_text_login"
                android:textSize="14sp" />

        </android.support.design.widget.TextInputLayout>

【问题讨论】:

    标签: android android-layout android-edittext android-textinputlayout


    【解决方案1】:

    我还没有尝试过,所以我不确定它是否有效,但是您是否尝试过为包装 TextInputLayout 的父布局添加填充?

    看起来您的 TextInputLayout 具有标准/默认提示填充。因此,也许您应该尝试让父布局考虑 TextInputLayout 的提示和 EditText 视图之间的大间距。

    我在这里写了一篇关于 TextInputLayouts 的快速帖子,其中可能有更多提示可以帮助您?:w3bshark.com/blog/input-layouts

    【讨论】:

    • 我照你说的做了。我添加了一个 RealtiveLayout,我现在只有这个元素。每个填充,边距我都给了相对布局,现在它可以工作了。太糟糕了,你不能只添加填充。
    【解决方案2】:

    在 Edittext 中使用填充

      <android.support.design.widget.TextInputLayout
            android:id="@+id/login_layout_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="12dp"
            android:layout_marginEnd="36dp"
            android:layout_marginStart="36dp"
            android:background="@color/color_line_transparent"
            android:gravity="center"
            android:theme="@style/TextLabel"
            app:errorTextAppearance="@style/TextAppearance.Design.Error">
    
            <EditText
                android:id="@+id/login_input_email"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingEnd="16dp"
                android:paddingStart="16dp"
                android:layout_gravity="center"
                android:hint="@string/hint_email"
                android:inputType="textEmailAddress"
                android:textColor="@color/color_text_login"
                android:textSize="14sp" />
    
      </android.support.design.widget.TextInputLayout>
    

    【讨论】:

    • 还是一样的结果。
    【解决方案3】:

    提示设置错误,提示应该设置在 textinputlayout 而不是 edittext 上。

    【讨论】:

      猜你喜欢
      • 2021-11-03
      • 2017-04-18
      • 2015-08-15
      • 2018-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多