2017-02-21 62 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> 
相關問題