意外的 Android 文件结尾

时间:2021-07-06 17:56:11

标签: android

我正在处理一个项目,遇到文件意外结尾的错误并且找不到源。我对 Android Studio 还很陌生,所以我不知道它没有关闭的地方。我试过不同的结束标签都无济于事,所以我不知道在哪里关闭它。任何提示和解决方案表示赞赏!

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fff"
    android:orientation="vertical"
    android:padding="20dp"
    tools:context=".VendorForm">

    <ImageView
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:src="@drawable/njftrus"
        android:transitionName="logo_image" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="-20dp"
        android:fontFamily="@font/bungee"
        android:text="Welcome,"
        android:textColor="#000"
        android:textSize="40sp"
        android:transitionName="logo_text" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Enter information about you and your truck!"
        android:textSize="18sp"
        android:transitionName="logo_desc" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="20dp"
        android:orientation="vertical">
        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/reg_name"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Full Name">
            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="text" />
            com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/reg_truckname"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Truck Name"
                app:counterMaxLength="15">
                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="text" />
                com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/reg_email"
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Email">

                    <com.google.android.material.textfield.TextInputEditText
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="textEmailAddress" />
                    com.google.android.material.textfield.TextInputLayout>
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/reg_phoneNo"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Phone No">
                        <com.google.android.material.textfield.TextInputEditText
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="number" />
                        com.google.android.material.textfield.TextInputLayout>

                                <Button
                                    android:id="@+id/reg_btn"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:background="#000"
                                    android:text="SAVE"
                                    android:textColor="#fff"
                                    android:transitionName="button_tran" />
                        LinearLayout>

1 个答案:

答案 0 :(得分:1)

所有 com.google.android.material.textfield.TextInputLayout 都错误地关闭, 这是一个基本的xml。 您可以使用 /> 关闭标签,或者如果需要让孩子使用 </tag>

例如:

 <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/reg_truckname"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Truck Name"
            app:counterMaxLength="15">
            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="text" />
            </com.google.android.material.textfield.TextInputLayout>

最底部的 LinearLayout

也是如此

基础教程:Android Developers - Declaring Layout (XML)

相关问题