Message : ImageView 에서 selector 가 안되는 현상


Solution : Clickable 설정을 추가한다.


android:clickable="true"



※ 이하 clickable 적용된 참고소스

1. layout 폴더에서 imageview가 적용된 xml 파일 중 일부입니다.

...

<ImageView

android:id="@+id/sample_img"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="@drawable/sample_selector"

android:contentDescription="@string/sample_img"

android:clickable="true"

/>

...


2. drawable 폴더에서 sample_selector.xml 소스입니다.


<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android" >

    

    <item android:state_pressed="true" android:drawable="@drawable/green" />

    <item android:state_selected="true" android:drawable="@drawable/red" />

    <item android:drawable="@drawable/yellow" />


</selector>



참조 링크 : http://shinluckyarchive.tistory.com/473

+ Recent posts