<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
When I made android application, I see sentence in head of XML File. But I don't know the meaning of it.
I assume you are talking about
<?xml version="1.0" encoding="UTF-8"?>
http://www.w3schools.com/xml/xml_tree.asp
Quoting from the link above
The first line is the XML declaration. It defines the XML version (1.0).
Also check
http://en.wikipedia.org/wiki/UTF-8
<LinearLayout xmlns:android="schemas.android.com/apk/res/android";
Its a LinearLayout that you have in xml
xmlns- its xml name space
A quick search on the same topic on stackoverflow gives the below links which should anser your question
Why this line xmlns:android="http://schemas.android.com/apk/res/android" must be the first in the layout xml file?
What does "xmlns" in XML mean?
I think you are talking about this line <?xml version="1.0" encoding="utf-8"?>
That line actually defines the version of .xml file.
Please refer to XML Standards
In xml Header this is ?xml version="1.0" the xml VERSION you are defining. This is the ENCODING TYPE of xml to be defined encoding="utf-8"? . And this is the NAMESPACE of xml xmlns:android="http://schemas.android.com/apk/res/android" hope this help.
Related
in the layout xml files that we create . we sometimes use '#' & '?' attribute what does it mean
For e.g i created toolbar.xml . i could see the ?android:attr/actionBarSize what does this mean
& what does #android:style/**ThemeOverlay.Material.Dark.ActionBar" mean
<?xml version="1.0" encoding="utf-8"?>
<Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="**?android:attr/actionBarSize**"
android:background="**?android:attr/colorPrimary**"
android:theme="**#android:style/**ThemeOverlay.Material.Dark.ActionBar"/>
If you read the document about ResourcesFromCode, you will find
if you use #..., that means a syntax to reference a resource in an XML resource:
#[<package_name>:]<resource_type>/<resource_name>
And if you use ?..., that means you are referencing a style attribute and the resource type portion is optional:
?[<package_name>:][<resource_type>/]<resource_name>
You can get more examples and detailed information in the document.
And here is a link that may help: question-mark-in-xml-attributes-for-android
-- EDIT --
I know what xmlns are thank you:)
-- END EDIT --
i can not find any documentation on the res-auto and lib-auto android namespaces. These appears at the top of xml layout files:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="#CCCCCC"
android:layout_width="match_parent"
android:layout_height="match_parent">
I remarked that aapt2 requires the use of lib-auto instead of res-auto. But don't know why.
xmlns:app="http://schemas.android.com/apk/lib-auto"
And what if you don't have any xml layout file, and you still need to include all resources from a library. What would be the "code" version of lib-auto ?
I have a problem with this xml file as said in the title.
I dont know how to solve the problem as i have already searched a lot and only found answers like use clean or change validation of this type to ignore
none of the above worked as i want to clear this problem so that my R will be generet in the gen folder.
Hope someone can see the problem soon as this is my examprojekt im working on and cant get further without solving this error :)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Dekrypter" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world" />
</RelativeLayout>
Start your XML with:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE RelativeLayout>
The solution is to put on the top of xml this code. It identify the type of the document to encode!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
Revalidate the project!
CIAO!!!
I retrieve a solution from a bug issue :
Click Window > Preferences > XML > XML Files > Validation
Change the setting 'validating files'>'No grammar specified' from warning to ignore.
Re-validate your project. No more warnings now.
It works for me.
Add
<?xml version="1.0" encoding="utf-8"?>
To the top of your XML file. This tells the parser that your file is indeed an XML, that it should use XML version 1.0, and that you are using utf-8 encoding.
Without it, the parser doesn't know how it should parse your XML.
First put this :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
and after that do this structure:
Click Window > Preferences > XML > XML Files > Validation
Change the setting 'validating files'>'No grammar specified' from warning to ignore.
Re-validate your project. No more warnings now.
thank you AntoineP and TecnoHelp83
https://stackoverflow.com/a/19314230/3117196
https://stackoverflow.com/a/22973854/3117196
worked as well
I created two layout files.
Android XML Layout File which created this xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
and an Android XML File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
From the looks of it they are both the same. When to use one over the other since they are both creating the same xml?
Yeah they are prograticaly the same, there isn't different type of xml. What matters, is the location of the xml (layout, values, ...).
In eclipse, there maybe is a small difference in the IDE view, i'm not sure that you have the Graphical Layout view if you create a Android XML file instead of a layout file (it's a detail because, you still can add this view ;) )
But results apk will be identical.
The reason why you would use an Android XML, is if you wanted to use the Layout Tool (the GUI layout editor). The Eclipse IDE will react to this file differently.
But, the code is the same, so the APK you create will also be the same - it doesn't matter in your final output.
I always use Android XML files, so they integrate into the ADT tools better.
the only difference as far as I can see is that in xml you can't use both "android:layout-width:" and "android:layout-height:" attributes which makes xml for example suitable for the use of menu and item bar and other uses.
I am trying to add a new layout to the framework say my_layout.
I succeeded partially in that .
I defined my layout in an xml and put it inside frameworks/base/core/res/res/layout
I then mentioned the id in frameworks/base/core/res/res/values
public.xml and ids.xml
And after performing a complete build :
make framework
make update-api
make
i am able to access it as android.R.layout.my_layout
But now i want to access it through xml also :Eg: "#android:layout/my_layout"
In which place in the source do i mention this reference ?
Try to declare the id in your my_layout.xml file in your layout folder.
for example:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
...
Happy coding :)