#android-studio #android-fragments #android-scrollview #android-nestedscrollview
#android-studio #android-фрагменты #android-scrollview #android-nestedscrollview
Вопрос:
У меня есть фрагмент, к которому я перешел с помощью современного интерфейса навигации. Проблема, с которой я сталкиваюсь, заключается в том, что просмотр прокрутки не начнет прокручиваться, если просмотр не длинный. Это нормально, и я понимаю, но возникает проблема, когда ввод текста редактирования, который находится в нижней части экрана, скрывается при открытии клавиатуры, поэтому вы не можете видеть, когда вы вводите ключ, следовательно, причина необходимости прокрутки для прокрутки вниз, чтобы вид можно было прокручивать над клавиатурой
Есть ли способ инициировать просмотр прокрутки, чтобы, когда клавиатура скрывает ввод текста редактирования, я все еще мог прокручивать вверх и видеть, что я ввожу
Мой фрагмент узла навигации
<fragment
android:id="@ id/nav_host_fragment"
android:layout_below="@ id/app_bar_layout"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_graph"
android:layout_above="@ id/bottom_nav"/>
Мой макет фрагмента, который имеет вид прокрутки и не прокручивается
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.ScrollFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="5dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First Name"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Second Name"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Phone Number"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Gender"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="country"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="province"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="County"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="province"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="region"
android:layout_margin="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="village"
android:layout_margin="5dp"/>
</LinearLayout>
</ScrollView>
Если я добавлю больше вида и макет будет достаточно длинным, просмотр прокрутки будет работать нормально, но он не прокручивается, когда просмотры еще не достигли дна клавиатура скрывает вид, и я не могу видеть, что я печатаю в редактируемом тексте
Я попытался использовать вложенный вид прокрутки и установить
app:layout_behavior="@string/appbar_scrolling_view_behavior"
но он все еще не работает.
Я также попытался установить следующие свойства для просмотра прокрутки
android:isScrollContainer="false"
android:fitsSystemWindows="true"
android:fillViewport="true"
Комментарии:
1. у вас есть решение вышеуказанной проблемы?
2. Я только что добавил пробел <Пробел android: id=»@ id /space» android:layout_width=»match_parent» android: layout_height=»250dp» android:layout_below=»@ id / btn_login» />