In my android app, I need to set background inside an image resource. On attempting to do that, the spaces around the image takes the background as well, but I want the image background to be only inside the image.
<ImageView
android:id="@+id/pen"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5px"
android:src="@drawable/pencil"
android:background="#000"
android:layout_toRightOf="@id/upcount"/>
I have tried to do it programmatically as well but getting the same result
pen.setBackgroundColor(Color.rgb(100, 100, 50));
this is sample of what I try to achieve. let the background be only on the pencil