0

我有以下布局,并试图使布局滚动。我添加了一个 ScrollView,但我必须将它放在错误的位置。有android布局知识的任何人都可以帮忙吗?

这是我的xml:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    android:id="@+id/myScrollLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:background="@drawable/gradient"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/filterOptions">
        <TextView
            android:id="@+id/tvHeaderText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginLeft="0dp"
            android:layout_marginRight="0dp"
            android:text=""
            android:textColor="#ffffffff"
            android:textSize="20sp"
            android:shadowColor="#7F000000"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="2"
            android:layout_centerVertical="true"
            android:paddingTop="3dp"
            android:paddingBottom="3dp"
            android:background="@drawable/gradientNews" />
        <TextView
            android:id="@+id/textView1"
            android:text="Distance"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/relativeLayout1">
            <Spinner
                android:id="@+id/spWithinMiles"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/textView1"
                android:textColor="#FF0000" />
        </RelativeLayout>
        <TextView
            android:id="@+id/tvPracticeType"
            android:text="Practice Type"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/relativeLayout2">
            <Spinner
                android:id="@+id/spPracticeType"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/tvPracticeType"
                android:textColor="#FF0000" />
        </RelativeLayout>
        <TextView
            android:id="@+id/tvForeignLanguage"
            android:text="Language"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/relativeLayout3">
            <Spinner
                android:id="@+id/spForeignLanguage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/tvForeignLanguage"
                android:textColor="#FF0000" />
        </RelativeLayout>
        <TextView
            android:id="@+id/tvTreatmentOptions"
            android:text="Treatment Options"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/rlTreatmentOptions">
            <CheckBox
                android:text="Handicapped Accessible"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ff000000"
                android:id="@+id/cbHandicappedAccessible" />
            <CheckBox
                android:text="Home Visits"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbHandicappedAccessible"
                android:textColor="#ff000000"
                android:id="@+id/cbHomeVisits" />
            <CheckBox
                android:text="Treat Age One"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbHomeVisits"
                android:textColor="#ff000000"
                android:id="@+id/cbTreatAgeOne" />
            <CheckBox
                android:text="Treat Special Needs"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbTreatAgeOne"
                android:textColor="#ff000000"
                android:id="@+id/cbTreatSpecialNeeds" />
            <CheckBox
                android:text="Grin &amp; Wear It Mouthguard"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbTreatSpecialNeeds"
                android:textColor="#ff000000"
                android:id="@+id/cbGrinWearItMouthguard" />
        </RelativeLayout>
        <TextView
            android:id="@+id/tvPracticeOptions"
            android:text="Practice Options"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/rlPracticeOptions">
            <CheckBox
                android:text="Website"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ff000000"
                android:id="@+id/cbWebsite" />
            <CheckBox
                android:text="Early hours"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbWebsite"
                android:textColor="#ff000000"
                android:id="@+id/cbEarlyHours" />
            <CheckBox
                android:text="Late hours"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbEarlyHours"
                android:textColor="#ff000000"
                android:id="@+id/cbLateHours" />
            <CheckBox
                android:text="Saturday hours"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbLateHours"
                android:textColor="#ff000000"
                android:id="@+id/cbSaturdayHours" />
            <CheckBox
                android:text="Multispecialty Practice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbSaturdayHours"
                android:textColor="#ff000000"
                android:id="@+id/cbMultispecialtyPractice" />
        </RelativeLayout>
    </LinearLayout>
</ScrollView>
4

1 回答 1

2

如前所述f20k

xlmns:android="..." 应该在最上面的布局

看一看 :

<?xml version="1.0" encoding="utf-8"?>
<ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myScrollLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="vertical"
        android:background="@drawable/gradient"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/filterOptions">
        <TextView
            android:id="@+id/tvHeaderText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginLeft="0dp"
            android:layout_marginRight="0dp"
            android:text=""
            android:textColor="#ffffffff"
            android:textSize="20sp"
            android:shadowColor="#7F000000"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="2"
            android:layout_centerVertical="true"
            android:paddingTop="3dp"
            android:paddingBottom="3dp"
            android:background="@drawable/gradientNews" />
        <TextView
            android:id="@+id/textView1"
            android:text="Distance"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/relativeLayout1">
            <Spinner
                android:id="@+id/spWithinMiles"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/textView1"
                android:textColor="#FF0000" />
        </RelativeLayout>
        <TextView
            android:id="@+id/tvPracticeType"
            android:text="Practice Type"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/relativeLayout2">
            <Spinner
                android:id="@+id/spPracticeType"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/tvPracticeType"
                android:textColor="#FF0000" />
        </RelativeLayout>
        <TextView
            android:id="@+id/tvForeignLanguage"
            android:text="Language"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/relativeLayout3">
            <Spinner
                android:id="@+id/spForeignLanguage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/tvForeignLanguage"
                android:textColor="#FF0000" />
        </RelativeLayout>
        <TextView
            android:id="@+id/tvTreatmentOptions"
            android:text="Treatment Options"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/rlTreatmentOptions">
            <CheckBox
                android:text="Handicapped Accessible"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ff000000"
                android:id="@+id/cbHandicappedAccessible" />
            <CheckBox
                android:text="Home Visits"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbHandicappedAccessible"
                android:textColor="#ff000000"
                android:id="@+id/cbHomeVisits" />
            <CheckBox
                android:text="Treat Age One"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbHomeVisits"
                android:textColor="#ff000000"
                android:id="@+id/cbTreatAgeOne" />
            <CheckBox
                android:text="Treat Special Needs"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbTreatAgeOne"
                android:textColor="#ff000000"
                android:id="@+id/cbTreatSpecialNeeds" />
            <CheckBox
                android:text="Grin &amp; Wear It Mouthguard"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbTreatSpecialNeeds"
                android:textColor="#ff000000"
                android:id="@+id/cbGrinWearItMouthguard" />
        </RelativeLayout>
        <TextView
            android:id="@+id/tvPracticeOptions"
            android:text="Practice Options"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16sp"
            android:textColor="#ff000000" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/rlPracticeOptions">
            <CheckBox
                android:text="Website"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ff000000"
                android:id="@+id/cbWebsite" />
            <CheckBox
                android:text="Early hours"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbWebsite"
                android:textColor="#ff000000"
                android:id="@+id/cbEarlyHours" />
            <CheckBox
                android:text="Late hours"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbEarlyHours"
                android:textColor="#ff000000"
                android:id="@+id/cbLateHours" />
            <CheckBox
                android:text="Saturday hours"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbLateHours"
                android:textColor="#ff000000"
                android:id="@+id/cbSaturdayHours" />
            <CheckBox
                android:text="Multispecialty Practice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cbSaturdayHours"
                android:textColor="#ff000000"
                android:id="@+id/cbMultispecialtyPractice" />
        </RelativeLayout>
    </LinearLayout>
</ScrollView>
于 2013-02-19T14:41:00.857 回答