yosh
yosh

Reputation: 3305

Android app theme - difference when using theme from style xml file

Why is there a difference between theme defined in AndroidManifest.xml and theme taken from styles.xml?

1) AndroidManifest.xml:

<application ... android:theme="@android:style/Theme.Black">

2) AndroidManifest.xml

<application ... android:theme="@style/AppTheme">

styles.xml

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

1st setting gives black theme and no action bar. 2nd has dark action bar and light menu.

EDIT : options 1) and 2) - notice Menu and ActionBar

enter image description here enter image description here

EDIT 2:

Why doesn't the 2nd option actually use the AppTheme (Theme.Black) ? (tested on SGS3)

Upvotes: 5

Views: 28902

Answers (4)

Brian White
Brian White

Reputation: 8736

You probably have another styles.xml file, perhaps under a directory like "values-v11", that is defining the @style/AppTheme differently than @android:style/Theme.Black and taking precedence over the file you're viewing/modifying.

Upvotes: 9

dadeguitar
dadeguitar

Reputation: 1

You should try to put:

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

in a xml file called res/themes.xml

Upvotes: 0

waqaslam
waqaslam

Reputation: 68177

@android:style/Theme.Black implements the exact theme implemented by Android (or device manufacturer). However, @style/AppTheme allows you to perform custom modification in your theme which actually extends the original Theme.Black from android, and in order to perform custom modifications, you use style resources.

In simple words, its just like using Activity class or YourOwnActivity class which extends Activity with extra features inside.

Upvotes: 2

Fl&#225;vio Faria
Fl&#225;vio Faria

Reputation: 6605

Styles.xml enables you to create your own themes. In AndroidManifest, you set the theme you want for an app or activity. You may want to use a system theme or your own. You can also extend other themes as you're doing setting "parent" attribute. For further information, check this out:

http://developer.android.com/guide/topics/ui/themes.html

Upvotes: 0

Related Questions