2017-02-21 65 views
1

我无法在我的XML文件中使用TextInputLayout。 所以,我收到了很多错误。 已添加依存关系和例外的屏幕截图。 我试图用TextInputLayout我的EditText awhere一个是在登录页面我无法使用TextInputLayout的EditText上

Dependencies

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:background="#e3e3e3" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:padding="@dimen/activity_horizontal_margin" 
tools:context=".MainActivity" 
android:orientation="vertical"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.5" 
    android:orientation="vertical"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:gravity="center" 
     android:text="Welcome" 
     android:textSize="30sp" 
     android:textColor="#333333"/> 

</RelativeLayout> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.5" 
    android:orientation="vertical"> 

    <android.support.design.widget.TextInputLayout 
     android:id="@+id/usernameWrapper" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <EditText 
      android:id="@+id/username" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="textEmailAddress" 
      android:hint="Username"/> 

    </android.support.design.widget.TextInputLayout> 

    <EditText 
     android:id="@+id/password" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textPassword"/> 

    <Button 
     android:id="@+id/btn" 
     android:layout_marginTop="4dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Login"/> 

</LinearLayout> 

+0

修复语法错误 – ErmIg

回答

0

打开下面根据依赖关系的依赖应用程序的build.gradle &粘贴电子邮件和密码Exception in my android Studio部分。

compile 'com.android.support:appcompat-v7:23.0.1' 
compile 'com.android.support:design:23.0.1' 

之后,重建你的项目。

P.S. : - 您必须在TextInputLayout中包装EditText以获取密码。

0

你能尝试点击该图标,选择程序兼容性主题?

enter image description here

0

首先检查的build.gradle里你compileSdkVersion并在此支持库设置版本。

编译 'com.android.support:appcompat-v7:23.0.1' 编译 'com.android.support:design:23.0.1'

而且你还可以使用TextInputEditText与TextInputLayout这样

<android.support.design.widget.TextInputLayout 
    android:id="@+id/usernameWrapper" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.design.widget.TextInputEditText 
     android:id="@+id/username" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textEmailAddress" 
     android:hint="Username"/> 

</android.support.design.widget.TextInputLayout> 
相关问题