@Niko - thanks for your trollish and completely incorrect response...

@EveryoneElse:

I did some quick and dirty testing and found that I could at least
change the namespace from android: to a:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout   xmlns:a="http://schemas.android.com/apk/res/android";
        a:orientation="vertical"
        a:layout_width="fill_parent"
        a:layout_height="fill_parent">

        <TextView
                a:layout_width="fill_parent"
                a:layout_height="wrap_content"
                a:text="@string/hello" />

</LinearLayout>


This seems to work with the ADT layout editor as well, so when new
views are added, they use a: for the attributes.

Not a great solution, but still easier to read for me.  And it handles
the id vs android:id problem.




On Mar 11, 9:42 am, Lance Nanek <[email protected]> wrote:
> I did some quick tests to see if there was any way to use the default
> namespace or if there was any sort of automatic mapping to android as
> mentioned above. I didn't find anything that works.
>
> Android projects start with this default layout which works fine:
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     android:orientation="vertical"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent"
>     >
> <TextView
>     android:layout_width="fill_parent"
>     android:layout_height="wrap_content"
>     android:text="@string/hello"
>     />
> </LinearLayout>
>
> Removing the namespace declaration and prefixes entirely doesn't work:
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout
>     orientation="vertical"
>     layout_width="fill_parent"
>     layout_height="fill_parent"
>     >
> <TextView
>     layout_width="fill_parent"
>     layout_height="wrap_content"
>     text="@string/hello"
>     />
> </LinearLayout>
>
> Just removing the prefix on the attributes doesn't work:
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     orientation="vertical"
>     layout_width="fill_parent"
>     layout_height="fill_parent"
>     >
> <TextView
>     layout_width="fill_parent"
>     layout_height="wrap_content"
>     text="@string/hello"
>     />
> </LinearLayout>
>
> And using the default namespace doesn't work (it shouldn't anyway, the
> default namespace doesn't apply to attributes):
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns="http://schemas.android.com/apk/res/android";
>     orientation="vertical"
>     layout_width="fill_parent"
>     layout_height="fill_parent"
>     >
> <TextView
>     layout_width="fill_parent"
>     layout_height="wrap_content"
>     text="@string/hello"
>     />
> </LinearLayout>
>
> They all got this exception:
>
> > java.lang.RuntimeException: Binary XML file line #2: You must supply a 
> > layout_width attribute.
>
> This isn't even getting into the issue with id vs. android:id
> mentioned in the other thread.
>
> On Mar 10, 10:18 am, niko20 <[email protected]> wrote:
>
> > Yes no kidding, learn XML properly and you'll know how to deal with
> > this...duh...
>
> > On Mar 10, 7:00 am, Tim <[email protected]> wrote:
>
> > > On Mar 10, 5:47 am, sstrenn <[email protected]> wrote:
>
> > > > It seems difficult to believe that this isn't handled in a default/
> > > > override manner.  The default requires no namespace, which
> > > > automatically maps to android:.
>
> > > Erm, I think you can do that if you want.
>
> > > Instead of:
>
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > > android"
> > >               android:layout_width="fill_parent"
> > >               android:layout_height="fill_parent"
> > >               android:orientation="vertical" >
> > > etc.
> > > </LinearLayout>
>
> > > You could use
>
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android";
> > >               a:layout_width="fill_parent"
> > >               a:layout_height="fill_parent"
> > >               a:orientation="vertical" >
> > > etc.
> > > </LinearLayout>
>
> > > or even
>
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <LinearLayout xmlns="http://schemas.android.com/apk/res/android";
> > >               layout_width="fill_parent"
> > >               layout_height="fill_parent"
> > >               orientation="vertical" >
> > > etc.
> > > </LinearLayout>
>
> > > I haven't actually tried this but I'm pretty sure it should work. 
> > > Seehttp://www.w3.org/TR/2006/REC-xml-names11-20060816/#scoping-defaulting

-- 
You received this message because you are subscribed to the Google Groups 
"Android Discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/android-discuss?hl=en.

Reply via email to