What does the AppBaseTheme app do in Android apps?

I can not understand what is happening with the AppBaseTheme in Android. In styles.xml, I have the following code

<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="mycolor"> <item name="android:background">@layout/header_gradient</item> <item name="android:padding">5dip</item> </style> <style name="myParentTheme" parent="android:Theme.Light"> <item name="android:attr/windowTitleSize">40dip</item> <item name="android:attr/windowTitleBackgroundStyle">@style/mycolor</item> </style> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> </style> 

In AndroidManifest.xml, when I use android: theme = "@ style / myParentTheme", the color and size of the header are set according to what I want to set. But the style for text fields is changing to old regular text fields. When I use android: theme = "@ style / AppTheme", the user interface looks very "similar to Android", but my specific settings for the name have no effect. Removing parent = "AppBaseTheme" makes the AppTheme style the same as myParentTheme.

Also, why can't I see all the elements of R.attr when I do Ctrl + Space when I enter the attribute name of the Style tag?

Please, help. Thanks.

+6
source share
1 answer

If you decide to create an event using the Create New Eclipse Wizard, Eclipse will determine the AppTheme and AppBaseTheme resources for you. AppBaseTheme will usually have three definitions in res/values/ , res/values-v11/ and res/values-v14/ . AppTheme inherits from AppBaseTheme .

The goal is to put most of the style information of your application into AppTheme , and not come up with your own theme (like myParentTheme ). AppBaseTheme basically ensures that you inherit the right theme supplied by the OS (e.g. Theme.Light vs. Theme.Holo.Light vs. Theme.Holo.Light.DarkActionBar ). You can also add version style information to the corresponding AppBaseTheme if you wish.

In AndroidManifest.xml , when I use android:theme="@style/myParentTheme" , the color and size of the header are set according to what I want to set. But the style for text fields is changing to old regular text fields.

This is because you inherit from Theme.Light , which uses an original (non-hogographic) widget set.

When I use android:theme="@style/AppTheme" , the user interface looks very "similar to Android", but my specific settings for the name have no effect.

This is because you decided to create myParentTheme instead of putting your style definitions in AppTheme .

+15
source

All Articles