gpt4 book ai didi

android - TextInputLayout,setError增加高度

转载 作者:行者123 更新时间:2023-12-05 04:49:24 31 4
gpt4 key购买 nike

我有一个简单的 TextInputLayout:

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilPwd"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Passcode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" >

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:singleLine="true" />

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

那我下面还有其他看法。

问题是,当我在 TextInputLayout 上设置错误时,高度会增加并插入下方的所有 View 。我尝试了一种设置空白 helperText 的变通方法,但是在对讲中将读取空白 helperText,这不是我想要的。

除了将 TextInputLayout 包装在具有设置高度的某个 ViewGroup 中之外,是否有一个干净的解决方案?

最佳答案

经过一天的尝试,我居然找到了解决方案:

public void setHelperTextEnabled (boolean enabled)

Whether the helper text functionality is enabled or not in this layout. Enabling thisfunctionality before setting a helper message viasetHelperText(CharSequence) will mean that this layout will not changesize when a helper message is displayed.

基本上它会提前占用 helperText 的空间(即使它没有设置),这与错误占用的空间相同。

值得注意的是等效的 xml 属性“app:helperTextEnabled”并没有解决这个问题。

关于android - TextInputLayout,setError增加高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67598291/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com