Android FrameLayouts 并排与独立的内部滚动

Android FrameLayouts side by side with independent internal scrolling

我正在尝试设置左侧为列表、右侧为详细信息窗格的平板电脑布局。单击列表项时,详细信息窗格将填充一系列比左侧列表更长的卡片。我希望详细信息窗格和列表(回收站视图)独立滚动,但我不知道该怎么做。

这是我的 main_content.axml - recyclerview 被加载到 framelayout listcontainer 中,细节被放置在 detailscontainer 中(textview 在这发生之前被删除) - 但两个框架仍然滚动 'as one' - 整个应用滚动,框架不单独滚动。

顺便说一句,main_content.xml 包裹在嵌套滚动视图中,这样我就可以使用折叠工具栏 - 您可以在此处查看 main.xml:http://pastebin.com/raw/PGsVuAp6

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

  <ScrollView
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_weight="1">
      <FrameLayout
          android:id="@+id/listcontainer"
          android:layout_weight="1"
          android:layout_width="450dp"
          android:layout_height="match_parent" >
      </FrameLayout>
  </ScrollView>

  <View android:layout_height="fill_parent"
    android:layout_width="1dp"
    android:background="?android:attr/listDivider"/>

  <ScrollView
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_weight="2">
    <FrameLayout
          android:id="@+id/detailscontainer"
          android:layout_width="match_parent"
          android:layout_weight="2"
          android:layout_height="match_parent" >
      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:id="@+id/nodetails"
        android:layout_centerInParent="true"
        android:layout_gravity="center"
        android:text="No inspection selected."/>

    </FrameLayout>
  </ScrollView>

</LinearLayout>

编辑,为清楚起见,这是加载到列表框中的内容:http://pastebin.com/raw/1Wm8Tntf ----- and here's what's loaded into the detail pane: http://pastebin.com/raw/FetE8JP1

编辑 2:这是一张图片,显示列表和详细信息这两个框架应该如何独立滚动,即当您滚动详细信息时,列表不应移动,当您滚动列表时,细节不应移动:

ScrollView 的 child 中使用 LinearLayout 而不是 FrameLayout,它会起作用!或者在 ScrollView

中尝试 android:fillViewport="true"

示例 xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ScrollView
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_weight="1">
        <LinearLayout
            android:orientation="vertical"
            android:id="@+id/listcontainer"
            android:layout_weight="1"
            android:layout_width="450dp"
            android:layout_height="match_parent" >
            <LinearLayout
                android:background="#897"
                android:layout_width="match_parent"
                android:layout_height="300dp"></LinearLayout>
            <LinearLayout
                android:background="#127"
                android:layout_width="match_parent"
                android:layout_height="300dp"></LinearLayout>
            <LinearLayout
                android:background="#908"
                android:layout_width="match_parent"
                android:layout_height="300dp"></LinearLayout>
        </LinearLayout>
    </ScrollView>

    <View android:layout_height="fill_parent"
        android:layout_width="1dp"
        android:background="?android:attr/listDivider"/>

    <ScrollView
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_weight="2">
        <LinearLayout
            android:orientation="vertical"
            android:id="@+id/listcontainerTwo"
            android:layout_weight="1"
            android:layout_width="450dp"
            android:layout_height="match_parent" >
            <LinearLayout
                android:background="#897"
                android:layout_width="match_parent"
                android:layout_height="300dp"></LinearLayout>
            <LinearLayout
                android:background="#127"
                android:layout_width="match_parent"
                android:layout_height="300dp"></LinearLayout>
            <LinearLayout
                android:background="#908"
                android:layout_width="match_parent"
                android:layout_height="300dp"></LinearLayout>
        </LinearLayout>
    </ScrollView>

</LinearLayout>

FrameLayout 只是一个容器,如果您使用 LinearLayout,那么在 ScrollView 场景中大部分时间都会出现问题,无论如何它都会滚动我已经测试过了。你可以找到笑脸问题 > here