Error parsing XML: not well-formed (invalid token)

NeidennXNeidennX Member ✭✭
edited July 28 in Xamarin.Android

I'm having this issue with 2 of my layouts whenever i try to run my app, this is the code that i have for the first layout

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/relativeLayout1"

<include layout="@layout/content_main" />
                                                -------------------->Error showing in this blank line
<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    app:srcCompat="@android:drawable/ic_dialog_email" />

<Button
    android:text="Resgistrar Estudiantes"
    android:layout_width="400px"
    android:layout_height="110px"
    android:layout_marginTop="250px"
    android:layout_marginLeft="180px"
    android:id="@+id/BtnRegEstudiante" />

/>

And this is the one the i have for my second layout

<?xml version="1.0" encoding="utf-8"?>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2"
android:rowCount="6"
android:id="@+id/gridLayout1"

<TextView
** android:layout_width="120px" ** --------Error showing in this line
android:layout_height="100px"
ad:minWidth="30px"
ndroiandroid:minHeight="30px"
android:paddingTop="60px"
android:paddingLeft="20px"
android:text="Nombre"
android:textColor="@android:color/black"
android:id="@+id/LblNombre"

/>

<EditText
android:id="@+id/TxtNombre"
android:layout_width="285px"
android:layout_height="100px"
android:minWidth="30px"
android:minHeight="30px"
android:paddingTop="40px"
android:paddingLeft="20px"
android:layout_marginLeft="150px"
/>

/>

Best Answer

  • NeidennXNeidennX ✭✭
    Accepted Answer

    I just found the error haha, i was missing a "="

       <Button
            android:id="@+id/BtnRegEstudiante"
            android:text="Registro de Estudiantes"
            android:layout_width="400px"
            android:layout_height="150px"
            android:layout_marginTop="250px"
            **android:layout_marginLeft="180px"/>**
    

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    For your second layout file, the controls should be placed in your GridLayout like:

    <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnCount="2"
        android:rowCount="6"
        android:id="@+id/gridLayout1">
    
        <!--... other children controls-->
    </GridLayout>
    

    For you first layout, please check whether content_main exists.

  • NeidennXNeidennX Member ✭✭

    @LandLu said:
    For your second layout file, the controls should be placed in your GridLayout like:

    <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnCount="2"
        android:rowCount="6"
        android:id="@+id/gridLayout1">
    
        
    </GridLayout>
    

    For you first layout, please check whether content_main exists.

    when i do that in the second layout, that section stops working

  • LandLuLandLu Member, Xamarin Team Xamurai

    What do you mean that section stops working?
    I created a sample for referring. Please see the attachment for more details.

  • NeidennXNeidennX Member ✭✭

    What i mean is that basically when i open and close like this

    <GridLayout 
        <!--... other children controls-->
    </GridLayout>
    

    the IDE is not recognizing that as a part of the code

    btw that sample is not letting me see the layouts :(

  • LandLuLandLu Member, Xamarin Team Xamurai

    What do you mean sample is not letting me see the layouts?
    You can't open the second_layout in my sample?

  • NeidennXNeidennX Member ✭✭

    Ok apparently it was an issue with my Visual Studio, i saw the file you sent, i edited some of my coded and part of it worked out for my, but the same issue is showing and this time that solution is not working :/

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay" />
    
        </android.support.design.widget.AppBarLayout>
    
        <include layout="@layout/content_main" />
    
        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="@dimen/fab_margin"
            app:srcCompat="@android:drawable/ic_dialog_email" />
    
            <Button
            android:id="@+id/BtnRegEstudiante"
            android:text="Registro de Estudiantes"
            android:layout_width="400px"
            android:layout_height="150px"
            android:layout_marginTop="250px"
            android:layout_marginLeft"180px"/>
    </android.support.design.widget.CoordinatorLayout>  The error is shown in this line
    
  • NeidennXNeidennX Member ✭✭
    Accepted Answer

    I just found the error haha, i was missing a "="

       <Button
            android:id="@+id/BtnRegEstudiante"
            android:text="Registro de Estudiantes"
            android:layout_width="400px"
            android:layout_height="150px"
            android:layout_marginTop="250px"
            **android:layout_marginLeft="180px"/>**
    
Sign In or Register to comment.