我有一个将ScrollView作为唯一孩子的FrameLayout。在运行时,我为其中包含ScrollView的RelativeLayout充气,并将其添加到FrameLayout(此子视图现在与以前的ScrollView重叠)。我已经将LockableScrollView用作FrameLayout的第一个子项,因此,可以通过将scrollable属性设置为false来禁用其滚动,将新的子项添加到FrameLayout之后,focusable和clickable属性也将设置为false。但是我仍然无法滚动新的ScrollView。有指针吗?

以下是“根”布局。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout
        android:id="@+id/relative_layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/questions_bg">

        <ImageView
            android:id="@+id/questions_header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:scaleType="fitXY"
            android:src="@drawable/header_bg" />

        <com.package.ui.LockableScrollView
            android:id="@+id/question_scrollview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@id/questions_header"
            android:scrollbarAlwaysDrawVerticalTrack="true"
            android:scrollbarStyle="insideOverlay"
            android:scrollbarFadeDuration="0"
            android:fillViewport="true">

            <!-- Some more views -->

        </com.package.ui.LockableScrollView>
    </RelativeLayout>
</FrameLayout>


以下是在运行时膨胀并添加到FrameLayout的子布局。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal"
    android:layout_marginBottom="20dp">

    <ImageView
        android:id="@+id/q_map_header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:src="@drawable/en_question_map_header" />

    <ImageView
        android:id="@+id/q_map_bg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@id/q_map_header"
        android:src="@drawable/question_map_content" />

    <ImageView
        android:id="@+id/q_map_footer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@id/q_map_bg"
        android:paddingBottom="50dp"
        android:src="@drawable/en_question_map_footer" />

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/q_map_header"
        android:layout_above="@id/q_map_footer"
        android:layout_marginLeft="28dp"
        android:layout_marginRight="30dp"
        android:layout_marginTop="14dp"
        android:layout_marginBottom="14dp"
        android:layout_alignLeft="@id/q_map_header"
        android:layout_alignRight="@id/q_map_header"
        android:fillViewport="true" >

        <GridView
            android:id="@+id/q_map_grid"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:numColumns="5"
            android:verticalSpacing="8dp"
            android:horizontalSpacing="8dp"
            android:stretchMode="columnWidth"
            android:gravity="center_horizontal" />
    </ScrollView>
</RelativeLayout>

最佳答案

您不能将可滚动容器(此处GridView)放置在另一个可滚动容器(此处ScrollView)中。

07-28 00:45
查看更多