我正在使用抽屉导航使用 this例子。我只想将蓝色更改为橙色,我该怎么做?我的意思是更改 ListView 选择器颜色,操作栏选择器颜色一切。
最佳答案
你可以使用选择器
在 drawable 文件夹中有如下的 selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/press" />
<item android:state_focused="false"
android:drawable="@drawable/normal" />
</selector>
在drawable文件夹下press.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FF9D21"/>
</shape>
在drawable文件夹下normal.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#8BC7EB"/>
</shape>
在 drawer_list_item.xml 中
android:background="@drawable/selector"
为栏设计样式
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<item name="android:background">@style/MyActionBar</item>
<!-- API 11 theme customizations can go here. -->
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/press</item>
</style>
</resources>
在你的 list 中
<activity
android:name=".MainActivity"
android:theme="@style/MyActionBar"
android:label="@string/app_name">
您可以为特定 Activity 而不是整个应用程序指定主题。
更多信息
http://android-developers.blogspot.in/2011/04/customizing-action-bar.html
https://developer.android.com/training/basics/actionbar/styling.html
快照
关于android - 抽屉导航改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18759798/