Why and when do we need to add android: prefix to style?

I saw that some style attributes require the android prefix, and some do not need it. What is the reason. as

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> 

Why we did not use android:windowActionBar and android:windowNoTitle

+8
android styles android-theme
source share
2 answers

Based on the SDK version, Android styles are grouped into different namespaces. To override a topic, you must follow its namespace.

For this reason, you do not need the android: prefix when expanding the AppCompat theme, but if you need something else, say Theme.Holo , you will have two different styles for them: one for pre-Lollipop and one for -21 , the latter has android: prefix android: before each style attribute.

+2
source share

It depends on what topics you use and in what context. These attributes are defined by different sources.

If the attribute name is prefixed with android: it is an attribute of the framework and can only be used for Android versions that it defines.

If an attribute has no prefixes at all, the attributes are determined by your own application. This includes all attribute definitions that you insert into libraries.

In your example, you define a theme for AppCompat , which is part of the support library and thus your application. Frame widgets will not recognize these colors directly.

0
source share

All Articles