Reputation: 400
how can i generate icon using 4 diffrent icons like gmail app have icon with text programmatically, i have spend couple of hours to generate it with TextDrawable but would not able to modify it to use with images
here is the screenshot what i am trying to achive
the numbers 1,2 etc will be replaced with other small images. any hint or help will be appreciated thanks.
Upvotes: 1
Views: 210
Reputation: 661
The easiest way is to use a gridlayout with 2 columns and 2 rows as well. You can fill it with your imageviews right in your xml layout file and can manipulate it in your activity/fragment code or even more in your adapter/viewholder
Upvotes: 0
Reputation: 1266
Use my layout construction which generate this image:
<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>
Upvotes: 1