ScrollView在FrameLayout中不起作用

时间:2017-03-01 05:56:43

标签: android

以下是我的代码当我放scrollview时,我无法滚动布局看起来很奇怪

<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"
    android:background="#0099cc"
    tools:context="willapp.stpl.com.willapp.util.ActivityPrintView">
    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:fillViewport="true"

        android:orientation="horizontal">



    <!-- The primary full-screen view. This can be replaced with whatever view
         is needed to present your content, e.g. VideoView, SurfaceView,
         TextureView, etc. -->

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/rootLayout">


        <LinearLayout
            android:id="@+id/table1heading"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Select executer's relationship"
                android:id="@+id/txtHeading"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="5dp"
            android:id="@+id/mainactivity_layoutName"
            android:layout_below="@+id/table1heading"
            android:layout_centerVertical="true" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/mainactivity_txtLabelName"
                android:text="Full Name:"/>

            <View
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_weight="1">

            </View>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/mainactivity_txtValueName"
                android:text="Sssdadaad"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:id="@+id/mainactivity_layoutLine1"
            android:padding="5dp"
            android:layout_below="@+id/mainactivity_layoutName"
            android:layout_centerVertical="true" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/mainactivity_txtLabelLine1"
                android:text="Address Line1:"/>

            <View
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_weight="1">

            </View>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/mainactivity_txtValueLine1"
                android:text="Sssdadaad"/>

        </LinearLayout>





        </RelativeLayout>
</ScrollView>



</FrameLayout>

1 个答案:

答案 0 :(得分:1)

ScrollView内部尝试使用LinearLayout代替RelativeLayout

这样的事情:

<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"
    android:background="#0099cc"
    tools:context="willapp.stpl.com.willapp.util.ActivityPrintView">
    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:fillViewport="true"

        android:orientation="horizontal">


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

       // and here your main Relative layout

       </LinearLayout>

    </ScrollView>
</FrameLayout>