Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 hereenter image description here

EDIT 2:

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

like image 680
yosh Avatar asked Dec 07 '12 13:12

yosh


People also ask

What is the difference between style and theme in Android?

A style is a collection of attributes that specify the appearance for a single View . A style can specify attributes such as font color, font size, background color, and much more. A theme is a collection of attributes that's applied to an entire app, activity, or view hierarchy—not just an individual view.

Is styles XML the same as themes XML?

There is no functional difference between styles. xml and themes.

What is the use of style .XML in Android?

A style is defined in an XML resource that is separate from the XML that specifies the layout. This XML file resides under res/values/ directory of your project and will have <resources> as the root node which is mandatory for the style file. The name of the XML file is arbitrary, but it must use the . xml extension.

Where is Styles XML file in Android Studio?

xml file in the new Android Studio. Goto your project file view: Res>Values>Themes folder. Open themes. xml file change actionbar.


2 Answers

@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.

like image 33
waqaslam Avatar answered Nov 15 '22 03:11

waqaslam


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.

like image 60
Brian White Avatar answered Nov 15 '22 03:11

Brian White