I have ImageButton that have an icon inside.
The ImageButton and icon background are transparent.
i would like to know how can i add shadow to the icon ? the shadow should be able to be ON/OFF.
if anyone can help with stroke as well i will appreciate it very much.
this is my imageButton –
<ImageButton
android:id="@+id/icon"
android:layout_width="140dp"
android:layout_height="60dp"
android:layout_gravity="center_horizontal"
android:layout_weight="0.76"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:onClick="showIconSelector"
android:src="@drawable/icon_0" />
You should use a drawable for this. Here is an example of a rectangle with a gradient, a stroke, and rounded corners. There are lots of possibilities using these:
This would be placed in your drawable folder, then can be referenced the same way you would reference any drawable resource.
To make this work with On\Off state, you will need to create a selector, that uses different drawables for each state you want to account for.