У меня есть реализация сетки в recyclerview с использованием кнопкуШирина сетки, как описано здесь:Квадратные элементы для AutoFitRecyclerView сетки
http://blog.sqisland.com/2014/12/recyclerview-autofit-grid.html
Однако мои элементы сетки не являются квадратами (они являются прямоугольниками), несмотря на крепления сетки размер элемента. Есть ли способ, чтобы сделать квадрат элементов (как в реальных GridView
) при сохранении свойства Автоподбора
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>
Отлично! 'SquareFrameLayout' - спаситель – stud91