Android Scrollviewer 不在包含其他元素的相对布局内滚动

Android Scrollviewer not scrolling inside Relative Layout with other elements

如果有相同的问题,我找不到了。大多数帖子没有在滚动查看器中正确设置布局。

在下文中,我无法拥有作为滚动查看器子项的线性布局滚动。我已经隐藏了一些不相关的 ID 和名称。滚动之外的所有内容似乎都按预期工作。

<RelativeLayout
                p1:minWidth="25px"
                p1:minHeight="25px"
                p1:layout_width="fill_parent"
                p1:layout_height="fill_parent"
                p1:id="@+id/rl_DisplayOutter">
                <TableLayout
                    p1:minWidth="25px"
                    p1:minHeight="25px"
                    p1:layout_width="fill_parent"
                    p1:layout_height="wrap_content"
                    p1:stretchColumns="*"
                    p1:shrinkColumns="*"
                    p1:id="@+id/tl_tableHeader">
                    <TableRow>
                        <TextView
                            p1:text="Date"
                            p1:textAppearance="?android:attr/textAppearanceMedium"
                            p1:id="@+id/tv_date"
                            p1:layout_margin="1dp"
                            p1:gravity="center_horizontal"
                            p1:textSize="18dp"
                            p1:layout_width="100dp"
                            p1:textStyle="bold" />
                        <TextView
                            p1:text="Time"
                            p1:textAppearance="?android:attr/textAppearanceMedium"
                            p1:id="@+id/tv_time"
                            p1:layout_margin="1dp"
                            p1:gravity="center_horizontal"
                            p1:textSize="18dp"
                            p1:layout_width="100dp"
                            p1:textStyle="bold" />
                        <TextView
                            p1:text="Client/User"
                            p1:textAppearance="?android:attr/textAppearanceMedium"
                            p1:id="@+id/tv_client"
                            p1:layout_margin="1dp"
                            p1:gravity="center_horizontal"
                            p1:textSize="18dp"
                            p1:layout_width="130dp"
                            p1:textStyle="bold" />
                        <TextView
                            p1:text="Summary"
                            p1:textAppearance="?android:attr/textAppearanceMedium"
                            p1:id="@+id/tv_summary"
                            p1:layout_margin="1dp"
                            p1:gravity="center_horizontal"
                            p1:textSize="18dp"
                            p1:layout_width="250dp"
                            p1:textStyle="bold" />
                    </TableRow>
                </TableLayout>
                <ScrollView
                    p1:layout_width="fill_parent"
                    p1:layout_height="0dp"
                    p1:id="@+id/sv_scrollNoifHome"
                    p1:fadeScrollbars="false"
                    p1:layout_above="@+id/rl_notification" 
                    p1:layout_below="@id/tl_tableHeader"
                    p1:fillViewport="true"
                    p1:focusable="true">
                    <LinearLayout
                        p1:minWidth="25px"
                        p1:minHeight="25px"
                        p1:orientation="vertical"
                        p1:layout_width="fill_parent"
                        p1:layout_height="fill_parent"
                        p1:id="@+id/ll_llSamplehome" />
                </ScrollView>
                <RelativeLayout
                    p1:minWidth="25px"
                    p1:minHeight="25px"
                    p1:layout_width="wrap_content"
                    p1:layout_height="wrap_content"
                    p1:id="@+id/rl_Buttons"
                    p1:layout_alignParentBottom="true"
                    p1:layout_centerHorizontal="true"
                    p1:layout_marginBottom="20dp">
                    <Button
                        p1:text="Acknowledge"
                        p1:layout_width="150dp"
                        p1:layout_height="wrap_content"
                        p1:id="@+id/btn_acknowledge" />
                    <Button
                        p1:text="Review Later"
                        p1:layout_width="wrap_content"
                        p1:layout_height="wrap_content"
                        p1:layout_toRightOf="@id/btn_acknowledge"
                        p1:id="@+id/btn_reviewLater"
                        p1:layout_marginLeft="20dp" />
                    <Button
                        p1:text="Take Me There"
                        p1:layout_width="wrap_content"
                        p1:layout_height="wrap_content"
                        p1:layout_toRightOf="@id/btn_reviewLater"
                        p1:id="@+id/btn_takeMeThere"
                        p1:visibility="gone"
                        p1:layout_marginLeft="20dp" />
                    <Button
                        p1:text="Close"
                        p1:layout_width="wrap_content"
                        p1:layout_height="wrap_content"
                        p1:layout_toRightOf="@id/btn_takeMeThere"
                        p1:id="@+id/btn_close"
                        p1:layout_marginLeft="20dp" />
                  </RelativeLayout>
            </RelativeLayout>

是否有人能够就我可能对其布局进行哪些布局或其他更改以在滚动查看器内实现可滚动线性布局作为整体相对布局的嵌套元素向我指出正确的方向?

旁注:内容被添加到列表视图并通过自定义适配器分配给线性布局 - 有数百个项目,因此内容肯定是 "scrollable"。我还注意到滚动条本身确实在布局加载时最初出现 - 表明它已经包裹了线性布局并且 should/could 可以滚动。然而,任何滚动尝试都不起作用,布局的内容保持不变。

如有任何提示或建议,我们将不胜感激。

您可能不希望您的 LinearLayout 具有 fill_parent 的高度,因为 ScrollView 的想法是当子视图包装它的内容时您希望能够滚动浏览它。

To understand this result, you must remember that android:layout_height=”fill_parent” means “set the height to the height of the parent.” This is obviously not what you want when using a ScrollView. After all, the ScrollView would become useless if its content was always as tall as itself.

来源:ScrollView's handy tricks

另一件事,我没有看到您正在谈论的 ListView,所以我假设您正在谈论动态添加它?为什么不在 XML 布局中定义它,并摆脱 ScrollView,因为 ListView 无论如何都是可滚动的。一旦您能够对此做出回应,我将更改我的答案,但如果是这种情况,我建议仅将 ScrollView 替换为 ListView。