Wednesday, 15 August 2012

android - Namespace of element declaring a namespace? -



android - Namespace of element declaring a namespace? -

in xml such as:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:orientation="vertical" <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="24dp" android:text="@string/question_text" /> </linearlayout>

what namespace of linearlayout , textview elements?

would http://schemas.android.com/apk/res/android namespace? or not in namespace @ all?

lastly, attributes have explicitly define namespace belong to, if any?

with widgets supplied android, not need utilize total bundle declaration bare class names (ex linearlayout, textview, etc.). if create custom widget, you'll have utilize bundle based declaration (ex. com.example.android.myawesomewidget).

only root widget requires android xml namespace (xmlns:android="http://schemas.android.com/apk/res/android") because of kid elements inherit namespace. means 1 time define namespace in root element not need place in kid elements.

and finally, attributes must explicitly utilize namespace prefix avoid confusion , collision. ex: android:layout_width="match_parent" valid layout_width="match_parent" not.

android xml

No comments:

Post a Comment