Create icon group in android

Viewed 44

I am new in android, I want to create icon group like this image , but cant find any resources, i had put recyclerview in cardview to achive this then cardview onClick on not working

        <androidx.cardview.widget.CardView
        android:id="@+id/cv_apps"
        app:cardCornerRadius="8dp"
        app:cardElevation="8dp"
        android:clickable="true"
        android:focusable="true"
        android:layout_margin="16dp"
        android:layout_width="120dp"
        android:layout_height="120dp">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_apps2"
            android:layout_margin="8dp"
            app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
            app:spanCount="3"
            tools:itemCount="10"
            tools:listitem="@layout/item_app2"
            android:layout_width="100dp"
            android:layout_height="100dp" />

    </androidx.cardview.widget.CardView>
1 Answers

This should work fine with a grid layout in a card view:

<androidx.cardview.widget.CardView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:backgroundTint="@color/card"
        app:cardCornerRadius="20dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:clickable="true"
        android:focusable="true">

    <GridLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical"
        android:columnCount="3"
        android:rowCount="3"
        android:padding="5dp">

        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />
        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />
        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />
        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />
        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />
        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />
        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />
        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />
        <ImageView
            android:layout_margin="1dp"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:src="@drawable/Download" />

    </GridLayout>

</androidx.cardview.widget.CardView>

Result:

enter image description here

Related