本機操作欄使用主題屬性selectableItemBackground
來執行操作項背景繪製。這應該是一個可繪製的狀態列表。
這裏的聲明中Theme.Holo
:
<style name="Theme.Holo">
<!-- bunch of things -->
<item name="android:selectableItemBackground">@android:drawable/item_background_holo_dark</item>
<!-- bunch of things -->
</style>
而其繪製XML:
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<!-- 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_disabled_holo_dark" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_disabled_holo_dark" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_dark" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_dark" />
<item android:state_focused="true" android:drawable="@drawable/list_focused_holo" />
<item android:drawable="@color/transparent" />
</selector>
感謝您的快速反應。但是,如果我嘗試用類似於 我收到一個錯誤:找不到與給定名稱匹配的資源:attr 'selectableItemBackground'。如何或在哪裏可以覆蓋此屬性? – Alf
對不起,您必須使用'name =「android:selectableItemBackground」'。它沒有在主題的Android平臺版本中指定,因爲它的默認包已經是'android'了。我更新了答案。 –
完美的作品,非常感謝你! – Alf