Jeder Artikel sollte 70% der Bildschirmbreite abdecken. Obwohl 70% des Bildschirms gefüllt sind, erhalte ich 30% Leerraum und der nächste Gegenstand beginnt danach. Hier ist das Layout -Horizontaler RecyclerView nicht wrapping Layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="4"
app:cardCornerRadius="2dp"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:contentPadding="2dp"
app:layout_widthPercent="70%">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/image_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>
</FrameLayout>
</android.support.v7.widget.CardView>
</android.support.percent.PercentRelativeLayout>
Versuchen einstellen 'App: layout_widthPercent = "70%"' zu 'PercentRelativeLayout' und setzen' CardView' auf 'match_parent' –
Das Problem ist nicht mit diesem Layout, es ist mit dem Layout, das die recyvlerview hält. Wenn Sie layout_margintop an einer beliebigen Stelle hinzugefügt haben, entfernen Sie diese bitte. – Jois
@IvanIvanov Wie können Sie dem PercentRelativeLayout selbst eine prozentuale Breite zuweisen? Das letzte Mal, wenn ich den Prozentsatz überprüfe, ist relativ. – mjosh