首页 > 解决方案 > 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>

标签: android

解决方案


All com.google.android.material.textfield.TextInputLayout are incorrectly closed, this is a basic xml. You can either close the tag with /> or if needed to have a child use </tag>

For example:

 <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>

Same goes for the very bottom LinearLayout

Basic tutorial: Android Developers - Declaring Layout (XML)


推荐阅读