无法实例化以下类:- android.support.design.widget.TextInputLayout



我搜索了很多。但我无法解决此问题。

我在项目中添加了appcompatv7design库。但是我收到此错误。

Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be instantiated:
- android.support.design.widget.TextInputLayout (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.

我的 xml 文件是

<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fitsSystemWindows="true">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="56dp"
            android:paddingLeft="24dp"
            android:paddingRight="24dp">
            <ImageView android:src="@drawable/maitri_icon"
                android:layout_width="wrap_content"
                android:layout_height="72dp"
                android:layout_marginBottom="24dp"
                android:layout_gravity="center_horizontal" />
            <!--  Name Label -->
            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp">
                <EditText android:id="@+id/input_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textCapWords"
                    android:hint="Name" />
            </android.support.design.widget.TextInputLayout>
            <!-- Email Label -->
            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp">
                <EditText android:id="@+id/input_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textEmailAddress"
                    android:hint="Email" />
            </android.support.design.widget.TextInputLayout>
            <!-- Password Label -->
            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp">
                <EditText android:id="@+id/input_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"
                    android:hint="Password"/>
            </android.support.design.widget.TextInputLayout>
            <!-- Signup Button -->
            <android.support.v7.widget.AppCompatButton
                android:id="@+id/btn_signup"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:layout_marginBottom="24dp"
                android:padding="12dp"
                android:text="Create Account"/>
            <TextView android:id="@+id/link_login"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="24dp"
                android:text="Already a member? Login"
                android:gravity="center"
                android:textSize="16dip"/>
        </LinearLayout>
    </ScrollView>

任何答案都会帮助我。

将其添加到您的应用程序级别 buid.gradle

compile 'com.android.support:design:23.1.1'

如果使用日食

将设计库从 sdk\extras\android\support\design 导入 eclipse 工作区,并将设计项目标记为库 -> 选择安卓 ->检查库

导入设计库后,需要按如下方式编辑 project.properties 文件:

# Project target.
target=android-21
android.library.reference.1=../v7/appcompat
android.library=true

相关内容

  • 没有找到相关文章

最新更新