[英]Scroll nestedscrollview to bottom of textView
I have some editText
in my activity so put them into nestedScrollView
and my activity has the adjustResize
attribute.我的活动中有一些editText
,因此将它们放入nestedScrollView
,并且我的活动具有adjustResize
属性。 I put a textView at bottom of each editText to show the exitText input error.我在每个editText的底部放了一个textView来显示exitText输入错误。 But their visibility
are Gone
.但他们的visibility
已经Gone
。 When the soft-keyboard open I don't have a problem whit the first exitText
, when I click on Next
button of the soft-jetboard nestedScrollView
scrolled to the bottom of next editText
and if user write a wrong input to my editText
the textView
of them will be visible and show the error of input to the user.当软键盘打开时,第一个exitText
没有问题,当我单击软喷射板的Next
按钮时, nestedScrollView
滚动到下一个editText
的底部,如果用户向我的editText
写入错误的输入,则textView
的它们将是可见的,并向用户显示输入错误。
BUT PROBLEM IS .但问题是。
They are below of their editText
.他们在他们的editText
。 How I can scroll nestedScrollView
to the bottom of the textView
?如何将textView
滚动到nestedScrollView
的底部?
You could just use TextInputEditText
and TextInputLayout
instead of EditText
and TextView
.您可以只使用TextInputEditText
和TextInputLayout
而不是EditText
和TextView
。
The scrolling behavior will be managed by Android's system and should result correctly.滚动行为将由 Android 系统管理,并且结果应该正确。
Also, it will simplify your code:此外,它将简化您的代码:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_input_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hint"/>
</com.google.android.material.textfield.TextInputLayout>
You can set and remove errors with:您可以设置和删除错误:
Java Java
text_input_layout.setError("Error message");
text_input_layout.setError(null);
Kotlin Kotlin
text_input_layout.error = "Error message"
text_input_layout.error = null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.