0

sometring怪在我的应用程序正在发生的事情,当我试图通过动作条的颜色变化也ListView的颜色

<style name="CustomAppTheme" parent="Theme.AppCompat.Light"> 
    <item name="android:background">#ff00</item> 
    <item name="android:textColor">#DCDCDC</item> 
</style> 

改变动作条的颜色也改变了我的ListView的颜色和其他活动如下变化全部内容。这是为什么?如何解决这个问题?

的ListView:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/listviewbackground" 
android:orientation="vertical" > 

<ListView 
    android:id="@+id/list" 
    android:longClickable="true" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent"> 
</ListView> 

回答

1

该文档是非常直接的,当涉及到重写default color & styles of the action bar。我假设您可能在res/values/styles.xml上更改了应用程序的资源样式文件。我也假设,在你的AndroidManifest.xml中,你已将下列属性的application标签:

android:theme="@style/AppTheme" 

再次,从documentation

样式是集合指定视图或窗口的外观和格式的属性。样式可以指定诸如高度,填充,字体颜色,字体大小,背景颜色等属性。样式是在与指定布局的XML分开的XML资源中定义的。

所以,当您更改styles.xml文件,你在不经意间改变背景颜色应用中的所有元素。

按照link 1的指示,你会很好。具体来说,

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <!-- the theme applied to the application or activity --> 
    <style name="CustomActionBarTheme" 
      parent="@android:style/Theme.Holo.Light.DarkActionBar"> 
     <item name="android:actionBarStyle">@style/MyActionBar</item> 
    </style> 

    <!-- ActionBar styles --> 
    <style name="MyActionBar" 
      parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse"> 
     <item name="android:background">@drawable/actionbar_background</item> 
    </style> 
</resources> 
+0

你是真的,我再次检查,再次,它的工作原理。谢谢你的时间! – waclab1807 2015-03-30 22:54:17

+0

很高兴为您提供帮助。如果你愿意接受答案,这个世界将是一个更美好的地方! ;) – abest 2015-03-31 12:20:25