无法在NestedScrollView中滚动ScrollView

时间:2017-08-01 14:39:54

标签: android scrollview bottom-sheet nestedscrollview

我正在使用带有BottomSheetBehavior的NestedScrollView。它有一个直接子项,一个ScrollView。当底页展开时,我希望能够滚动ScrollView中的内容,因为即使它被展开,在没有滚动的情况下查看仍然太多了。但是,它没有回应。这是XML:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.thunderbuild.weegnet.fragments.FragmentBridgesMap">

    <com.google.android.gms.maps.MapView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/bridges_mv_map"
            app:mapType="normal" />

    <android.support.v4.widget.NestedScrollView
            android:id="@+id/bridges_nsv_sheet"
            android:layout_width="match_parent"
            android:elevation="4dp"
            android:layout_height="350dp"
            android:scrollbars="none"
            android:background="@android:color/white"
            android:clipToPadding="true"
            app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

        <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clickable="true"
                android:id="@+id/bridge_sv_content">

            <android.support.constraint.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_constraintTop_toBottomOf="@+id/bridge_mv_map"
                    android:id="@+id/bridge_cl_content"
                    android:orientation="vertical">


                <TextView
                        android:id="@+id/bridge_tv_name"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:text="Bridge name"
                        android:textColor="@color/primaryTextColor"
                        android:textSize="20sp"
                        android:layout_marginTop="8dp"
                        android:layout_marginBottom="0dp"
                        app:layout_constraintBottom_toTopOf="@+id/linearLayout"
                        app:layout_constraintTop_toTopOf="parent"
                        android:layout_marginLeft="8dp"
                        app:layout_constraintLeft_toLeftOf="parent"
                        android:layout_marginRight="8dp"
                        app:layout_constraintRight_toRightOf="parent" />

                <Button
                        android:id="@+id/bridge_btn_weigh"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Weigh"
                        android:layout_gravity="center_horizontal"
                        android:background="@drawable/button_style"
                        android:textColor="@color/lightTextColor"
                        app:layout_constraintTop_toBottomOf="@+id/ll_opening_times"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintRight_toRightOf="parent"
                        android:layout_marginTop="8dp" />

                <TextView
                        android:id="@+id/bridge_tv_status"
                        android:layout_width="wrap_content"
                        android:textColor="@color/green"
                        android:layout_gravity="center_vertical"
                        android:layout_height="wrap_content"
                        android:text="Opened until..."
                        app:layout_constraintLeft_toLeftOf="@+id/bridge_tv_name"
                        app:layout_constraintTop_toBottomOf="@+id/bridge_tv_name"
                        android:layout_marginTop="8dp" />

                <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_marginRight="0dp"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@+id/bridge_tv_status"
                        app:layout_constraintBottom_toBottomOf="@+id/bridge_tv_status"
                        android:layout_marginEnd="8dp"
                        android:id="@+id/linearLayout">

                    <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:tint="@color/secondaryTextColor"
                            android:layout_marginRight="4dp"
                            android:src="@drawable/ic_car" />

                    <TextView
                            android:id="@+id/bridge_tv_eta"
                            android:layout_gravity="center_vertical|right"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="5 min." />
                </LinearLayout>

                <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_marker"
                        android:id="@+id/imageView"
                        android:tint="@color/colorPrimary"
                        android:layout_marginLeft="16dp"
                        app:layout_constraintLeft_toLeftOf="parent"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"
                        app:layout_constraintTop_toBottomOf="@+id/bridge_tv_status" />

                <LinearLayout
                        android:id="@+id/ll_opening_times"
                        android:orientation="vertical"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/view"
                        android:layout_marginTop="8dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginRight="8dp" />

                <TextView
                        android:text="Address"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/bridge_tv_address"
                        app:layout_constraintLeft_toLeftOf="@+id/ll_opening_times"
                        app:layout_constraintBottom_toBottomOf="@+id/imageView"
                        app:layout_constraintTop_toTopOf="@+id/imageView" />

                <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_clock"
                        android:tint="@color/colorPrimary"
                        android:id="@+id/imageView2"
                        app:layout_constraintTop_toTopOf="@+id/ll_opening_times"
                        app:layout_constraintLeft_toLeftOf="@+id/imageView" />

                <View
                        android:layout_width="0dp"
                        android:layout_height="1dp"
                        android:background="@color/secondaryTextColor"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/bridge_tv_address"
                        app:layout_constraintRight_toRightOf="parent"
                        android:layout_marginTop="16dp"
                        app:layout_constraintHorizontal_bias="0.0"
                        android:id="@+id/view" />
            </android.support.constraint.ConstraintLayout>
        </ScrollView>
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

我尝试了here提到的解决方案,但无济于事。任何人都知道如何解决这个问题?

编辑:我现在注意到我可以滚动,但还不够远。内容在底部被切断。

1 个答案:

答案 0 :(得分:0)

其中一个问题是按钮没有底部约束。我添加了它,底部还有很多边距,这样就不会被切断。这是一个草率的解决方案,但现在有效。