У меня есть ScrollView
, содержащий один ConstraintLayout
, со многими Spinners
и их метками.
Всякий раз, когда я выбираю элемент в любом счетчике, просмотр прокрутки прокручивается вверх, и пользователь необходимо прокрутить обратно туда, где они были после каждого выбора.
Я пытался:
Но независимо от того, что я делаю, представление прокрутки переходит наверх после выбора элемента с вращающимся элементом.
Вот мой xml макет:
<ScrollView 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">
<androidx.constraintlayout.widget.ConstraintLayout
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/label2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner1" />
<TextView
android:id="@+id/label5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/label4" />
<TextView
android:id="@+id/label6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner6"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner5" />
<TextView
android:id="@+id/label8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/label7" />
<TextView
android:id="@+id/label4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner3" />
<TextView
android:id="@+id/label7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner7"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/label6" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/label1" />
<Spinner
android:id="@+id/spinner2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/label2" />
<Spinner
android:id="@+id/spinner3"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label3"
app:layout_constraintEnd_toEndOf="parent" />
<Spinner
android:id="@+id/spinner5"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label5"
app:layout_constraintEnd_toEndOf="parent" />
<Spinner
android:id="@+id/spinner6"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label6"
app:layout_constraintEnd_toEndOf="parent" />
<Spinner
android:id="@+id/spinner7"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label7"
app:layout_constraintEnd_toEndOf="parent" />
<Spinner
android:id="@+id/spinner9"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="1dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label9"
app:layout_constraintEnd_toEndOf="parent" />
<Spinner
android:id="@+id/spinner8"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/label8" />
<TextView
android:id="@+id/label9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner9"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/label8" />
<Spinner
android:id="@+id/spinner4"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:entries="@array/yes_or_no"
app:layout_constraintBottom_toBottomOf="@+id/label4"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/label3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner2" />
<TextView
android:id="@+id/label1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:text="Test"
app:layout_constraintEnd_toStartOf="@+id/spinner1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
и массив
<string-array name="yes_or_no">
<item></item>
<item>Yes</item>
<item>No</item>
</string-array>```
Thank you