android 中的双垂直滚动视图?
您好,我有一个具有三个垂直线性布局的活动,其各自的布局权重和方向垂直。我在左右线性布局中添加了 10 个图像。中间布局是空的。
我想在左右线性布局中添加滚动视图,这样如果屏幕很小,用户就可以滚动以查看线性布局中的所有图像。
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:id="@+id/layoutPositionRow"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:padding="8px"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".2" android:layout_gravity="center_vertical">
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".6" android:layout_gravity="center_vertical">
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".2" android:layout_gravity="center_vertical">
</LinearLayout>
</LinearLayout>
是否有可能。
请向我推荐可用的链接或示例代码。
hi I have a activity with three vertical linear layout with respective layout_weight with orientation vertical . I have added 10 image to left and right linear layout . Middle layout is empty.
I want to add scroll view in both left and right linear layout , so that if screen is small , then user able to scroll to see all images in linear layout .
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:id="@+id/layoutPositionRow"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:padding="8px"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".2" android:layout_gravity="center_vertical">
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".6" android:layout_gravity="center_vertical">
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".2" android:layout_gravity="center_vertical">
</LinearLayout>
</LinearLayout>
Whether It is possible.
Please suggest me usable link or sample code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将可滚动布局包装到
ScrollView
中,如以下代码所示:在这里,由于使用了
layout_weight
,我将所有元素的layout_width
属性值设置为 0dp。另外,如果您想通过center_vertcial
在布局中定位元素,您应该使用android:gravity
属性而不是android:layout_gravity
。最后一个告诉系统如何在其 ScrollView 上定位布局。Just wrap your scrollable layouts into
ScrollView
s like in this code:Here, I used
layout_width
attribute value for all of the elements as 0dp because of usinglayout_weight
. And also if you would like to position elements in your layouts bycenter_vertcial
you should useandroid:gravity
attribute instead ofandroid:layout_gravity
. The last one tells the system how to position layouts on theirScrollView
s.