如果有相同的问题,我将找不到它。大多数帖子都没有在scrollviewer内部包含正确设置的布局。
在下面的内容中,我无法使线性布局滚动成为滚动查看器的子级。我已经遮盖了一些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>
在我可能对他的布局进行哪些布局或其他更改方面,有人可以为我指明正确的方向,以便在scrollviewer内部实现可滚动的线性布局,作为整体相对布局的嵌套元素吗?
旁注:内容将添加到列表视图中,并通过自定义适配器分配给线性布局-有数百个项目,因此内容肯定是“可滚动的”。我还注意到,滚动条本身确实会在加载布局时最初显示-表示它已经包装了线性布局并且应该/可以滚动。但是,任何滚动尝试均无效,并且布局的内容保持固定。
任何提示或建议,将不胜感激。
您可能不希望LinearLayout具有fill_parent的高度,因为ScrollView的想法是在子视图中包装您希望滚动的内容。
要了解此结果,您必须记住android:layout_height =” fill_parent”的意思是“将高度设置为父级的高度。” 当使用ScrollView时,这显然不是您想要的。毕竟,如果ScrollView的内容总是和自身一样高,它将变得毫无用处。
资料来源:ScrollView的便捷技巧
另一件事,我没有看到您正在谈论的ListView,所以我假设您正在谈论动态添加它?为什么不在XML布局中定义它,并摆脱ScrollView,因为ListView仍然可以滚动。一旦您能够对此做出回应,我将更改答案,但是如果是这种情况,我建议仅将ListView替换为ScrollView。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句