[英]Scroll nestedscrollview to bottom of textView
我的活動中有一些editText
,因此將它們放入nestedScrollView
,並且我的活動具有adjustResize
屬性。 我在每個editText的底部放了一個textView來顯示exitText輸入錯誤。 但他們的visibility
已經Gone
。 當軟鍵盤打開時,第一個exitText
沒有問題,當我單擊軟噴射板的Next
按鈕時, nestedScrollView
滾動到下一個editText
的底部,如果用戶向我的editText
寫入錯誤的輸入,則textView
的它們將是可見的,並向用戶顯示輸入錯誤。
但問題是。
他們在他們的editText
。 如何將textView
滾動到nestedScrollView
的底部?
您可以只使用TextInputEditText
和TextInputLayout
而不是EditText
和TextView
。
滾動行為將由 Android 系統管理,並且結果應該正確。
此外,它將簡化您的代碼:
<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>
您可以設置和刪除錯誤:
Java
text_input_layout.setError("Error message");
text_input_layout.setError(null);
Kotlin
text_input_layout.error = "Error message"
text_input_layout.error = null
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.