ich ein Raster Umsetzung des recyclerview haben mit der Autofit Raster wie hier beschrieben:Platz Artikel für AutoFitRecyclerView Gitter
http://blog.sqisland.com/2014/12/recyclerview-autofit-grid.html
jedoch meine Rasterelemente sind nicht Quadrate (sie sind Rechtecke) trotz der Gitterbefestigungs Artikelgröße. Gibt es eine Möglichkeit, die Gegenstände Platz zu machen (wie in tatsächlichen GridView
), während die autofit Eigenschaft beibehalten
item_grid_image.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/image_wrapper"
android:layout_width="140dp"
android:layout_height="140dp"
android:padding="1dp"
android:layout_centerInParent="true">
<com.makeramen.roundedimageview.RoundedImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="centerCrop"
tools:src="@drawable/file_directory" />
</FrameLayout>
fragment_recyclerview.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/grid_view_wrapper"
android:layout_marginStart="@dimen/default_margin"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.project.AutoFitRecyclerView
android:id="@+id/grid_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/count_text_view"
android:layout_alignParentTop="true"
android:columnWidth="140dp"
android:layout_centerInParent="true"
android:requiresFadingEdge="vertical"
tools:listitem="@layout/item_grid_image">
</com.project.AutoFitRecyclerView>
</RelativeLayout>
Großartig! 'SquareFrameLayout' ist der Retter – stud91