ScrollView 在 CardView 中不起作用

eC *_*oid 6 android android-scrollview android-cardview

我已经搜索过了,但没有一个答案对我有帮助。

这是我的布局 xml:

<android.support.v7.widget.CardView
        android:id="@+id/layout_building"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/_8dp"
        app:layout_constraintEnd_toStartOf="@+id/scrollview_nested_fragment_container"
        app:layout_constraintHorizontal_weight="1"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/views_container">

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

        <LinearLayout
            android:id="@+id/layout_building_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"/>

        </ScrollView>

    </android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)

我正在LinearLayout通过代码向我的动态添加子视图。我也尝试将ScrollView标签移动到包装,CardView但仍然没有运气。这是限制CardView还是有人知道对此的有效解决方案。

eC *_*oid 2

好的,首先感谢大家提供宝贵的建议。实际问题出在ConstraintLayout. 所需要做的就是app:layout_constraintBottom_toBottomOf="parent"向卡片视图添加约束并设置android:layout_height="0dp"。卡片视图没有任何强制边界。与 LinearLayout 和relativelayout 不同,它们默认将边界强制到其子视图。