android:设计一个带有可滚动部分的活动

时间:2014-08-21 21:05:08

标签: android scrollview

我的活动包含以下4个部分:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"></LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"></LinearLayout>
    <ScrollView>
        <LinearLayout></LinearLayout>
    </ScrollView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"></LinearLayout>
</RelativeLayout>

scrollview的正确布局属性是什么?

2 个答案:

答案 0 :(得分:1)

试试这个

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"></LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"></LinearLayout>
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <!-- put your scrolling stuff here it needs
       to exceed the height of the view to scroll -->
</ScrollView>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"></LinearLayout>
</LinearLayout>

答案 1 :(得分:0)

我相信这应该有效..

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

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

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

            <!-- your layouts.. -->
            <!-- layouts in here will be in the scrollview -->
        </LinearLayout>
    </ScrollView>

</LinearLayout>