Scroll 动态添加元素后线性布局不滚动

Scroll 动态添加元素后线性布局不滚动,scroll,android-linearlayout,Scroll,Android Linearlayout,这是我的xml文件 <FrameLayout 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="www.oditorium.net.material_des

这是我的xml文件

<FrameLayout 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="www.oditorium.net.material_design_beta.fragment_layout3">


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scroll_view"
    android:orientation="vertical"
    android:fillViewport="true"
    android:layout_marginBottom="15dp">

    <LinearLayout
        android:id="@+id/linear"
        android:background="#006600"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </LinearLayout>

</ScrollView></FrameLayout>

我正在代码中向LinearLayout动态添加元素。但页面没有滚动。

使用以下代码:

<ScrollView
android:layout_width="match_parent"
android:layout_height="400dp"
android:id="@+id/scroll_view"
android:orientation="vertical"
android:fillViewport="true"
android:layout_marginBottom="15dp">

<LinearLayout
    android:id="@+id/linear"
    android:background="#006600"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

</LinearLayout>

在上面的代码中,我们修复了scrollview的大小。

使用下面的代码:

<ScrollView
android:layout_width="match_parent"
android:layout_height="400dp"
android:id="@+id/scroll_view"
android:orientation="vertical"
android:fillViewport="true"
android:layout_marginBottom="15dp">

<LinearLayout
    android:id="@+id/linear"
    android:background="#006600"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

</LinearLayout>

在上面的代码中,我们修复了scrollview的大小