【发布时间】:2014-12-18 21:28:49
【问题描述】:
我正在尝试更改我的 Android 应用的背景颜色,但我无法更改。我搜索了很多帖子,但没有一个解决方案能解决我的问题。
这是我的styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/ActionBar</item>
</style>
<style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#ff0000</item>
</style>
</resources>
如您所见,我只是想将栏设置为红色。 这是我的清单:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MenuActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
如您所见,主题设置正确。你可以看到,这是我的 gradle:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
所以,即使这看起来没问题,它并没有将我的 ActionBar 设置为红色。我尝试遵循很多指南(包括官方指南),并且按照他们所说的做了一切。我错过了什么?提前感谢您的耐心等待:)
【问题讨论】: