Như vậy là nhiều bước làm như vậy
Trước hết, bạn cần phải tạo ra một tùy chỉnh drawable với bốn tiểu bang, bạn có thể tham khảo {} ABSLibrary /res/drawable/abs__list_selector_holo_dark.xml. Nó sẽ là một cái gì đó như thế này:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@android: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/abs__list_selector_disabled_holo_dark" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abs__list_selector_disabled_holo_dark" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_background_transition_holo_dark" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_background_transition_holo_dark" />
<item android:state_focused="true" android:drawable="@drawable/abs__list_focused_holo" />
Save the drawable tùy chỉnh trên (.xml) vào res dự án của riêng bạn/drawable. Chỉnh sửa kiểu cho phù hợp bằng cách tham khảo mẫu ở trên. Xin lưu ý rằng phong cách có thể được lồng sâu, chỉ cần kiên nhẫn nhìn xuống cây.
Sau đó tạo (hoặc đưa vào chủ đề tùy chỉnh hiện) một chủ đề tùy chỉnh với những điều sau đây, nó phải được lưu lại dưới dạng res/values / styles.xml:
<style name="Theme.MyCustomTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="searchAutoCompleteTextView">@style/MySearchAutoCompleteTextView</item></style>
<style name="MySearchAutoCompleteTextView" parent="Sherlock.__Widget.SearchAutoCompleteTextView">
<item name="android:dropDownSelector">@drawable/myCustomDrawable_DropDown</item>
<item name="android:popupBackground">@drawable/myCustomDrawable_popupBackground</item></style>
Xin lưu ý rằng "myCustomDrawable_DropDown" và " myCustomDrawable_popupBackground "phải là tên của đối tượng vẽ tùy chỉnh mà bạn vừa tạo.
Bạn chỉ cần biết rằng "android: dropDownSelector" và/hoặc "android: popupBackground" là những người chịu trách nhiệm về việc theming của hộp bật lên tự động hoàn tất.
Cuối cùng, áp dụng chủ đề trong Tệp kê khai của bạn!
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyCustomTheme" > ...
Điều đó hoạt động tốt ngoại trừ màu văn bản không đúng nhưng tôi sẽ xem thêm – Benoit
@Benoit Đây 'một ví dụ về cách thay đổi màu văn bản - http://stackoverflow.com/a/ 14364222/1299623 – jimmithy
R.id.search_src_text là gì? –