【问题标题】:How to adjust the baseline length如何调整基线长度
【发布时间】:2021-01-15 21:37:50
【问题描述】:

如何调整TextInputEditText 的基线长度以完全匹配此示例:

我的TextInputEditText 现在看起来像:

我的意图是文本下方的行与提示对齐。

【问题讨论】:

    标签: java android xml material-components


    【解决方案1】:

    您可以将android:minLines 设置为2,将gravity 设置为底部。

    您可能还需要将高度指定为某个值,因为android:minLines 会根据行数增加高度。这里我设置为50dp

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Escreva seu feedback">
    
        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:gravity="bottom"
            android:paddingStart="0dp"
            android:paddingLeft="0dp" 
            android:minLines="2" />
    </com.google.android.material.textfield.TextInputLayout>
    

    结果:

    【讨论】:

      猜你喜欢
      • 2023-04-06
      • 2015-09-13
      • 1970-01-01
      • 2013-08-28
      • 2020-01-17
      • 2011-06-19
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多