我有一个滚动视图中的窗体,该窗体需要垂直滚动才能在显示键盘时显示窗体的其余部分。
我已将此添加到manifest.xml
android:windowSoftInputMode="stateVisible|adjustResize">
Fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBlack"
tools:context=".ui.main.ConnectFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:isScrollContainer="false"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
//My form
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
片段
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
navController = Navigation.findNavController(view)
我需要添加一些东西到onViewCreated吗?
在清单文件中,尝试将以下内容添加到activity
要在活动开始时显示键盘的:
android:windowSoftInputMode =“ stateVisible”
另外,为了在键盘显示时调整内容大小,您应该onCreate
在setContentView()
调用之前在方法中添加此代码
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句