2013-11-23 4 views
0

나는 기본적으로 포커스가있는 &이 활성화/활성화 된 3 가지 상태를 포함하는 버튼 선택기를 만들었습니다. 기본적으로 내 의도 ID는 @drawable/normal입니다. 터치/누를 때 @drawable/focused; 버튼이 활성화 된 경우 @drawable/enabled 하지만 작동하지 않습니다. &은 기본 (일반) 드로어 블만 표시합니다. 기본적으로 참조하십시오 대신 imageview.Imageview의버튼 선택기 드로어가 터치로 변경되지 않음

당김-hdpi에/button_selector.xml

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

    <item android:drawable="@drawable/enabled" android:state_pressed="true"></item> 
    <item android:drawable="@drawable/focused" android:state_focused="true"></item> 
    <item android:drawable="@drawable/normal"></item> 

</selector> 

layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    style="@style/AppBackground" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context=".RitualMainActivity" > 

    <include layout="@layout/merge_separator" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/button_selector" /> 

</LinearLayout> 

답변

0

시도해보십시오. 클릭 가능한 속성을 추가하여 .. 문제를 해결할 수 있습니다.

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clickable="true" 
    android:background="@drawable/button_selector" />