Reputation: 522
I've made an android-library consisting of two activities which are defined in the manifest of the library project and called from the other services in the same library. It works quite well so far but I don't want to hard code the design of the activities. Instead the main application which is using the library project should be able to change the style of the activities without having to include the activities in the manifest.
So I've created the attrs.xml in the library project defining all over-writable styles as references. Also a styles.xml where these attributes were preset with default values for the library project. But as I try to set the theme of the library application or the activity to ?attrs/themeRef the values are not applied to the layout. Note though that if I set the theme of the activities to use the predefined style with @style/NameOfTheme the values are applied. But that way I cant redefine the style in the main application.
Also it doesn't work if I set the theme of the main application to @NameOfTheme.
After two days of various combinations I cant get this to work. So the question is: is it even possible? If not, why?
Upvotes: 0
Views: 840
Reputation: 117
Create a theme in the main application that has the theme from the library as it's parent. Then override the attribute values in the new main application theme.
ActionBarSherlock's styled example, http://actionbarsherlock.com/theming.html, is an excellent reference on how to accomplish this.
Upvotes: 1