0
好的,所以我想创建一个在列表视图中具有并排图像视图的布局。 Here将是我想要实现的一个例子。但是,我真的不知道我应该如何做到这一点。这是我在网上找到的一个例子。问题是,一旦你开始添加更多的图像视图,它只是将它们添加到同一行,而不是现有的。如何将几个ImageView并排放置?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="15dip"
android:paddingBottom="15dip">
<ImageView android:id="@+id/numberDays"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:layout_weight="1"
android:src="@drawable/placeholder1" />
<ImageView android:src="@drawable/placeholder1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scaleType="fitStart"
android:layout_weight="1"
android:id="@+id/daysText"></ImageView>
</LinearLayout>
listview是一个更好的方法来并排显示这些图像,还是应该用XML来做这件事?
请使用gridview来实现这个 – Ramit
https://developer.android.com/guide/topics/ui/layout/gridview.html – Ramit
如果图片数量不固定,ListView或RecyclerView更好。我建议你使用RecyclerView和GridLayoutManager。这里是一个例子http://blog.sqisland.com/2014/12/recyclerview-grid-with-header.html?m=1 – nshmura