2013-08-02 2 views
3

새로운 ActionBarCompat 지원 라이브러리를 사용하고 있습니다.
작업 표시 줄의 동작 버튼은 눌렀을 때 배경을 변경해야합니다. Android 4.3에서는 작동하지만 진저 브레드에서는 작동하지 않습니다. 진저 브레드에서 버튼을 누르면 배경이 변경되지 않습니다. 나는 심지어 선택 변경 :ActionBarCompat 지원 라이브러리 android : selectableItemBackground가 작동하지 않습니다.

<style name="Theme.MyCustomTheme" parent="@style/Theme.AppCompat.Light"> 
    <item name="selectableItemBackground">@drawable/actionbar_item_bg_selector</item> 
</style> 

을 그리고 다시는 안드로이드 4.3이 아닌 진저 브레드와 함께 일하고있다. 이것은 버그입니까?

답변

1

문제가 무엇인지 알아 냈습니다. 안드로이드 선택기를 복사하고 수정해야합니다.

styles.xml

<style name="Theme.NewTransaction" parent="@style/Theme.AppCompat.Light.DarkActionBar"> 
     <item name="selectableItemBackground">@drawable/actionbar_item_bg_selector</item> 
</style> 

actionbar_item_bg_selector.xml

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

    <item android:state_window_focused="false" android:drawable="@color/transparent" /> 

    <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. --> 
    <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_disabled" /> 
    <item android:state_focused="true" android:state_enabled="false"        android:drawable="@drawable/list_selector_background_disabled" /> 
    <item android:state_focused="true"        android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" /> 
    <item android:state_focused="false"        android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" /> 
    <item android:state_focused="true"                android:drawable="@drawable/list_selector_background_focused" /> 
    <item android:drawable="@color/transparent" /> 

</selector> 

나는 내 문제는이 댓글에 관련되었다고 생각 :
을 비록 같은 자원이 두 점 , 두 가지 상태를 가지므로 눌려진 상태에서 나오면 drawable이 무효화됩니다.

관련 문제