I am unable to understand what happens with 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 title are set to what I want to set. But the style for text fields changes to the old regular textboxes. When I use android:theme="@style/AppTheme" the UI looks very "Android-like" but my specific settings to the title do not have any effect. Removing parent="AppBaseTheme" makes the AppTheme style behave just like the myParentTheme style.
Additionally, why do I not see all R.attr elements when I do Ctrl+Space while typing in the name attribute of the Style tag?
Please help. Thanks.
Best Answer
If you choose to create an activity using the Eclipse new-project wizard, Eclipse will define
AppTheme
andAppBaseTheme
resources for you.AppBaseTheme
typically will have three definitions, inres/values/
,res/values-v11/
, andres/values-v14/
.AppTheme
will inherit fromAppBaseTheme
.The intent is for you to put most of your app-specific style information in
AppTheme
, rather than inventing your own theme (e.g.,myParentTheme
).AppBaseTheme
would mostly ensure that you are inheriting from the right OS-supplied theme (e.g.,Theme.Light
vs.Theme.Holo.Light
vs.Theme.Holo.Light.DarkActionBar
). You can also add version-specific style information to the appropriateAppBaseTheme
if you wish.That is because you are inheriting from
Theme.Light
, which uses the original (non-holographic) widget set.That is because you decided to create
myParentTheme
instead of putting your style definitions intoAppTheme
.