Ich verwende eine CardView
mit ImageView
in RecyclerView
. Unten ist XML-Code.CardView mit ImageView in RecyclerView füllt nicht Bildschirm
List Item (CardView
) xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:elevation="20dp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:id="@+id/feed_cradImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/mysteps1"/>
</android.support.v7.widget.CardView>
Verwendung in einem RecyclerView
:
<android.support.v7.widget.RecyclerView
android:id="@+id/home_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
Aber ich einige Probleme bin vor.
1 => Ich habe gesetzt layout_width als "match_parent
" von CardView
und ImageView
. Aber, immer noch CardView
füllt nicht den gesamten Bildschirm und zeigt einen Rand in der rechten Seite.
2 => Wenn die Bildgröße in der Breite klein ist, dann CardView
wird nach Bildgröße schrumpfen. Ich möchte, dass die Karte nicht schrumpft, auch wenn sie leer ist oder ein kleines Bild enthält.
Hinweis: Ich verwende Picasso
für Bilder vom Server abgerufen werden.
android hilft: Scaletype = "fitXY" oder Android: Scaletype = "centerCrop" in ImageView –