在下面的代码中,我有两个主容器,一个RelativeLayout和一个ScrollView。我需要将RelativeLayout置于顶部固定的下方,我需要ScrollView,其中Images可以滚动。我有以下两个问题:
垂直LinearLayout中显示的图像视图是缩略图大小。如果我有15-20张图像,它们会占用很多垂直空间。如何根据屏幕大小使图像最大化,然后转到下一行?
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView>
</ImageView>
<ImageView>
</ImageView>
<ImageView>
</ImageView>
<ImageView>
</ImageView>
</LinearLayout>
</ScrollView>
答案 0 :(得分:3)
以简单的方式遵循这些:
<RelativeLayout>
。ScrollView
的高度设置为match_parent
。LinearLayout
。最后你会得到这个:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</RelativeLayout>
</LinearLayout>
答案 1 :(得分:1)
首先,您可以将RelativeLayout
的高度设置为固定值。然后将ScrollView
的高度设置为match_parent
,以便占用所有可用空间。然后,这两个都应该包含在垂直LinearLayout
中,以避免任何重叠。