2016-07-25 17 views
-1

enter image description hereIch möchte eine Listenansicht wie dieses Bild erstellen. Also welches Layout wäre dafür geeignet?

Ich möchte ein listview wie dieses Bild machen. Also welches Layout wäre dafür geeignet?

Ich verwende diesen XML-Code. Bitte sag mir wie ich wie dieses Bild komme. Zwischen zwei Listenpunkten ist der richtige Platz vorhanden.

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" />--> 
<!-- 
    &lt;!&ndash; Release Year &ndash;&gt; 
    <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> 

dies mit i wie dieses Bild bin immer.

enter image description here

+2

Siehe https://developer.android.com/training/material/lists-cards.html – sJy

+0

Ich möchte sagen, Vielen Dank. – user6313669

+1

RecyclerView + CardView. ODER (weniger performant) ListView + benutzerdefiniertes Zeilenelement. –

Antwort

1

Dieser Aufruf ist Cardview

In Gradle hinzufügen, um dieses

dependencies { 
     compile 'com.android.support:cardview-v7:21.0.0-rc1' 

} 

in Ihrem 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"/>