[ACCEPTED]-Android theme not being set-android-styles

Accepted answer
Score: 23

I've been struggling with this as well, and 10 think I've finally found what may have been 9 the problem - perhaps it is the same.

I had 8 the custom theme defined in the res\values folder, but 7 not in the values-v11 and values-v14 folders. Which I think 6 made it so that in some devices (specially 5 the 2 I was testing with!), the theme could 4 not be applied because it did not exist.

I 3 now see the properties set in my custom 2 theme (applied at the application level) taking 1 effect.

Score: 4

I had to explicitly define theme for every 1 <activity>.

Score: 3

According to this answer, it appears that it isn't possible to provide 8 layout_width and layout_height through styles. While it compiles, the 7 exception it raises is:

E/AndroidRuntime(4117): java.lang.RuntimeException: Unable to start activity
java.lang.RuntimeException: Binary XML file line #79: You must supply a
layout_width attribute.

I'm not sure why 6 that is, but there might be a workaround. As this question suggests, you 5 might be able provide a reference as the 4 width and height parameter.

Again, my experiences 3 are that Android doesn't properly support 2 providing the widget dimensions through 1 styles.

Score: 0

Just out of curiosity. Try renaming your 3 Theme to something else like FooBar.

Going 2 to state the obvious here, but make sure 1 your button is using the right style.

Score: 0

EDIT: I'm not sure if this was just a typo 6 in the question, but in your main theme 5 you reference Android's Theme.Black style 4 incorrectly. Your code says:

<style name="Theme" parent="android:style/Theme.Black">

When it should 3 say:

<style name="Theme" parent="@android:style/Theme.Black">

I feel like Lint or the compiler would 2 bark at you for that before running the 1 application, but maybe that will help.

More Related questions