NestedScrollView / ScrollView не прокручивается, когда какой-либо макет включен в дочерний элемент ScrollView - PullRequest
0 голосов
/ 26 марта 2020
androidx.core.widget.NestedScrollView
LinearLayout
androidx.constraintlayout.widget.ConstraintLayout
TextView
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
TextView
include
include
include

выше - это структура моего XML, когда я включаю макеты, прокрутка не работает.

Изначально включенные макеты - это Visibility GONE, и они становятся видимыми, когда флажок установлен. чекбоксов недостаточно, чтобы сделать экран прокручиваемым, но как только включенные макеты будут видны, scrollView должен прокрутиться. Но макет обрезается внизу и не прокручивается.

завершено XML:

<?xml version="1.0" encoding="utf-8"?>

<data>

    <variable
        name="annualRiskAssessmentVM"
        type="com.cmm_android.forms.risk_assessment.AnnualRiskAssessmentVM" />

    <variable
        name="fragment"
        type="com.cmm_android.forms.risk_assessment.AnnualRiskAssessmentFrag4" />

</data>


<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:padding="@dimen/_16sdp">


            <TextView
                android:id="@+id/tv2"
                style="@style/RegularBlack"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_8sdp"
                android:text="My support will include assistance with :"
                android:textAlignment="viewStart"
                app:layout_constraintTop_toBottomOf="@+id/tv1" />

            <CheckBox
                android:id="@+id/cbMedication"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_8sdp"
                android:text="Medication"
                app:layout_constraintTop_toBottomOf="@id/tv2" />

            <CheckBox
                android:id="@+id/cbPersonalCare"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Personal Care"
                app:layout_constraintTop_toBottomOf="@id/cbMedication" />

            <CheckBox
                android:id="@+id/cbNutrition"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Nutrition"
                app:layout_constraintTop_toBottomOf="@id/cbPersonalCare" />

            <CheckBox
                android:id="@+id/cbMoneyManagement"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Money Management"
                app:layout_constraintTop_toBottomOf="@id/cbNutrition" />

            <CheckBox
                android:id="@+id/cbShopping"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Shopping"
                app:layout_constraintTop_toBottomOf="@id/cbMoneyManagement" />

            <CheckBox
                android:id="@+id/cbSocialActivity"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Social activities or accessing the community"
                app:layout_constraintTop_toBottomOf="@id/cbShopping" />

            <CheckBox
                android:id="@+id/cbCompanionship"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Companionship (sitter service)"
                app:layout_constraintTop_toBottomOf="@id/cbSocialActivity" />

            <CheckBox
                android:id="@+id/cbWellbeing"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Wellbeing checks"
                app:layout_constraintTop_toBottomOf="@id/cbCompanionship" />

            <CheckBox
                android:id="@+id/cbDomestic"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Domestic"
                app:layout_constraintTop_toBottomOf="@id/cbWellbeing" />

            <CheckBox
                android:id="@+id/cbOther"
                style="@style/CheckBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_4sdp"
                android:text="Other"
                app:layout_constraintTop_toBottomOf="@id/cbDomestic" />


            <TextView
                android:id="@+id/tv3"
                style="@style/SmallBlack"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_8sdp"
                android:text="Now complete additional relevant sections below"
                app:layout_constraintTop_toBottomOf="@id/cbOther" />


            <include
                android:id="@+id/layout_medication"
                layout="@layout/layout_medication"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/tv3" />

            <include
                android:id="@+id/layout_personal_care"
                layout="@layout/layout_personal_care"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/layout_medication" />

            <include
                android:id="@+id/layout_nutrition"
                layout="@layout/layout_nutrition"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/layout_personal_care" />


        </androidx.constraintlayout.widget.ConstraintLayout>
    </LinearLayout>
</androidx.core.widget.NestedScrollView>

Я пошел через ряд сообщений на SO, но никто не связан с видимостью включенного макета.

1 Ответ

0 голосов
/ 26 марта 2020

Итак, это самая глупая ошибка, на которую ушел весь мой день.

Первый дочерний элемент моего макета ограничений ограничен основанием tv1, которого нет даже во всем макете. (Скопируйте ошибку вставки)

    <TextView
            android:id="@+id/tv2"
            style="@style/RegularBlack"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/_8sdp"
            android:text="My support will include assistance with :"
            android:textAlignment="viewStart"
            app:layout_constraintTop_toBottomOf="@+id/tv1" />

изменил его на

 app:layout_constraintTop_toTopOf="parent" 

, и прокрутка начала работать. :)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...