要获得正确的图像,您可以访问Android Asset Studio 站点并选择Android Holo Colors Generator。这将创建您可能需要的所有资产,包括“三角形”。它还生成实现更改的 XML 文件。
以下是示例 XML 文件:
自定义颜色:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="apptheme_color">#33b5e5</color>
</resources>
自定义微调器样式:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="SpinnerAppTheme" parent="android:Widget.Spinner">
<item name="android:background">@drawable/apptheme_spinner_background_holo_light</item>
<item name="android:dropDownSelector">@drawable/apptheme_list_selector_holo_light</item>
</style>
<style name="SpinnerDropDownItemAppTheme" parent="android:Widget.DropDownItem.Spinner">
<item name="android:checkMark">@drawable/apptheme_btn_radio_holo_light</item>
</style>
</resources>
自定义应用程序主题:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="@style/_AppTheme"/>
<style name="_AppTheme" parent="Theme.AppCompat.Light">
<item name="android:spinnerStyle">@style/SpinnerAppTheme</item>
<item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItemAppTheme</item>
</style>
</resources>
如您所见,这些样式还引用了许多可绘制对象。
这是您要更改的“三角形”特有的一个:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:drawable="@drawable/apptheme_spinner_disabled_holo_light" />
<item android:state_pressed="true"
android:drawable="@drawable/apptheme_spinner_pressed_holo_light" />
<item android:state_pressed="false" android:state_focused="true"
android:drawable="@drawable/apptheme_spinner_focused_holo_light" />
<item android:drawable="@drawable/apptheme_spinner_default_holo_light" />
</selector>
我认为这里不是完整列出每个文件的正确位置,因为您可以直接从引用的工具中获取所有文件。
注意:这是为整个应用设置主题的方式,以便所有微调器都更新为自定义样式。
如果您正在寻找一种快速而肮脏的方法来仅更改一个微调器,请查看 Ricky 在他的评论中引用的那篇文章:
我还是建议你阅读它,因为它很好地解释了这个过程,并且会帮助你理解我的其余答案。