Use android xml prefix (android :, app :, @ .., ...)

In AndroidStudio in an XML file, I do not understand the difference between an element with the android prefix and without it part of my source code, for example:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:textColorPrimary">@color/white</item> <item name="android:textColorSecondary">@color/white</item> <item name="actionMenuTextColor">@color/white</item> </style> <style name="AppTheme.toolbar" parent="Widget.AppCompat.Toolbar"> <item name="android:background">@color/grey</item> </style> 

in this XML file, why some attributes require a prefix (android :) and others not. for example:

 <item name="android:textColorPrimary">@color/white</item> 

this part of the code works correctly, but when the code below is used, it does not work: <item name="textColorPrimary">@color/white</item> So can someone help me find out the difference between the prefix and when I use it. thanks

+5
source share
1 answer

This is because some of these attributes belong to a different XML namespace. In the layout files, you might have seen something like:

 <Linear Layout xmlns:android="http://schemas.android.com/apk/res/android"> 

You need a way to tell the compiler that you will reference attributes from that location, and you do this with

 "android:" 
0
source

Source: https://habr.com/ru/post/1270887/


All Articles