Reputation: 3565
I am using android:theme=@style/AppTheme
for the application element in the manifest. The style.xml
file defines this style as
<style name="AppTheme" parent="@style/Theme.AppCompat">
So I expect the background of the activities and menu options to be dark by default, but it is white. I have not defined any background attributes in my layouts. What is the problem?
Here is my analysis of the Android source :
There is no background color defined in @style/Theme.AppCompat
or it's parent @style/Theme.Base.AppCompat
according to support themes.xml.
So i look at their parent @android:style/Theme
at base themes.xml . I see the below element :
<item name="colorBackground">@android:color/background_dark</item>
So i find out that the exact color of background_dark
is #ff000000
according to colors.xml
Why is Android not using this colour for my activities?
Upvotes: 0
Views: 677
Reputation: 280
I have same problem when I change theme in onCreate
method.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
updateTheme();
setContentView(R.layout.activity_blablabla);
}
I fix it by change order of updateTheme
and super.onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
updateTheme();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blablabla);
});
Upvotes: 0
Reputation: 3565
The problem was the the styles.xml
in values-v11
and values-v14
were using Theme.AppCompat.Light
.
Since my phone has API 19, it picks up these themes instead of from the values
folder, which had the styles.xml
with Theme.AppCompat
.
Upvotes: 1