我弄清楚了问题所在。您应该复制 android 选择器并对其进行修改。
样式.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 将使其自身无效。