2016-02-26 132 views
1

我搜索了lot.But无法解决此问题。以下类无法实例化: - 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> 

任何答案会帮助我。

+0

其中是'com.android.layoutlib.bridge.MockView' –

回答

0

添加到您的应用级buid.gradle

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

如果使用eclipse

导入设计库从SDK \演员\机器人\ SUPPORT \设计到Eclipse工作区和标志设计项目作为图书馆通过属性 - >选择Android的 - >检查库

+0

am使用eclipse – Rooban

0

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

# Project target. 
target=android-21 
android.library.reference.1=../v7/appcompat 
android.library=true 
相关问题