android gmail 应用程序喜欢一个图标中有 4 个图标的列表视图

android gmail app like List View with 4 icon in a icon

我如何使用 4 个不同的图标生成图标,例如 gmail 应用程序以编程方式带有带有文本的图标,我花了几个小时用 TextDrawable 生成它,但无法修改它以用于图像

这是我想要实现的截图

数字 1,2 等将替换为其他小图像。 任何提示或帮助将不胜感激谢谢。

使用生成此图像的布局构造:

 <LinearLayout
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:weightSum="2"
        android:orientation="vertical"
        android:background="#ffacacac"
        android:padding="2dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:orientation="horizontal"
            android:layout_weight="1"
            android:weightSum="2">

            <ImageView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_margin="2dp"
                android:background="#ffff2983"
                android:src="@android:drawable/presence_busy" />

            <ImageView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_margin="2dp"
                android:background="#ffa1ff55"
                android:src="@android:drawable/ic_menu_set_as" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:orientation="horizontal"
            android:layout_weight="1"
            android:weightSum="2">

            <ImageView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_margin="2dp"
                android:background="#ff5bffec"
                android:src="@android:drawable/ic_menu_send" />

            <ImageView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_margin="2dp"
                android:background="#ff4d4eff"
                android:src="@android:drawable/ic_menu_month" />

        </LinearLayout>

    </LinearLayout>

最简单的方法是使用 2 列和 2 行的网格布局。您可以在 xml 布局文件中用您的图像视图填充它,并可以在您的 activity/fragment 代码中对其进行操作,甚至可以在 adapter/viewholder

中进行操作