我有一个 FrameLayout,它有一个 ScrollView 作为唯一的 child 。在运行时,我膨胀了一个 RelativeLayout,其中有一个 ScrollView,并将它添加到 FrameLayout(这个 subview 现在与之前的 ScrollView 重叠)。我用过 LockableScrollView作为 FrameLayout 的第一个 child ,我可以通过将 scrollable 属性设置为 false 来禁用它的滚动,在将新 child 添加到 FrameLayout 后,可聚焦和可点击属性也设置为 false。但我仍然无法滚动新的 ScrollView。任何指针?
下面是Root布局
<?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)中。
关于android - 无法在 FrameLayout 上滚动 2 个 ScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6182909/