【发布时间】:2014-07-15 20:38:45
【问题描述】:
我想更改 Android 导航抽屉中所选项目的默认颜色(蓝色)。我已经让它在过去的项目中工作,但我不能在我目前正在进行的项目中工作。
这是应用主题。
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
<item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
<item name="android:buttonStyle">@style/AppTheme.Button</item>
</style>
这是激活的背景可绘制对象。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@drawable/list_selected"/>
<item android:state_selected="true" android:drawable="@drawable/list_selected"/>
<item android:state_pressed="true" android:drawable="@drawable/list_selected"/>
</selector>
最后,这是导航抽屉片段。
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#cccc"
tools:context=".NavigationDrawerFragment" />
就像我说的,这对我以前有用。我能想到的项目之间的唯一区别是,以前,我的应用程序主题是从“Theme.AppCompat”继承的,而这个项目的主题是从“android:Theme.Holo.Light.DarkActionBar”继承的。另外,我在新项目中使用 v4 支持片段,而在另一个项目中我只使用标准片段。
任何建议将不胜感激。谢谢。
【问题讨论】:
标签: android listview android-fragments