我想像这张图片一样listview
。那么什么布局适合这个呢?
我正在使用这个xml代码。请告诉我如何才能得到这样的图像。列表中的两个项目之间存在适当的空间。
list_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_row_selector"
android:padding="8dp" >
<!-- Thumbnail Image -->
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/thumbnail"
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="8dp" />
<!-- Restaurant name -->
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/thumbnail"
android:textSize="@dimen/title"
android:textStyle="bold" />
<TextView
android:id="@+id/area"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:textColor="#D2691E"
android:layout_toRightOf="@+id/thumbnail"
android:textSize="@dimen/rating" />
<!-- Rating -->
<TextView
android:id="@+id/average_ratings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/area"
android:textColor="#D2691E"
android:layout_toRightOf="@+id/thumbnail"
android:textSize="@dimen/rating" />
<TextView
android:id="@+id/cuisine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/average_ratings"
android:textColor="#D2691E"
android:layout_toRightOf="@+id/thumbnail"
android:textSize="@dimen/rating" />
<!-- Genre -->
<!-- <TextView
android:id="@+id/genre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rating"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/thumbnail"
android:textColor="@color/genre"
android:textSize="@dimen/genre" />-->
<!--
<!– Release Year –>
<TextView
android:id="@+id/releaseYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:textColor="@color/year"
android:textSize="@dimen/year" />-->
</RelativeLayout>
使用这个我就像这个图像。
答案 0 :(得分:1)
它被称为card view
使用recycler view
来获取卡片,它比列表视图更有效。
链接:https://developer.android.com/training/material/lists-cards.html
示例应用:http://www.androidhive.info/2016/05/android-working-with-card-view-and-recycler-view/
答案 1 :(得分:1)
这是致电Cardview
在Gradle中添加此
dependencies {
compile 'com.android.support:cardview-v7:21.0.0-rc1'
}
你的xml中的
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="4dp"
android:layout_margin="5dp"/>