1Effects to be achieved:
To implement the business, select the image effect.
Implemented:
2Solution:
The background attribute and padding attribute in the ImageView control are used to display the border outside the image, and the border background is changed through the control status to achieve click effect.
3Actual code:
<ImageView
android:id="@+id/img_1"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:focusable="true"
android:clickable="true"
android:tag="1"
android:background="@drawable/imgselect"
android:src="@drawable/sl1_1" />
imgselect (drawable)
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/img_on" />
<item android:state_pressed="true" android:drawable="@drawable/img_on" />
<item android:drawable="@drawable/img_off" />
</selector>