2016-12-13 10 views
1
나는 아름다운 레이아웃을 만들려고하고

로 시작, 내가 예를 발견했지만 제대로 동작하지 않습니다 :어떻게 재 설계

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_login" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="56dp" 
    android:paddingLeft="24dp" 
    android:paddingRight="24dp" 
    tools:context=".LoginActivity" 
    android:orientation="vertical"> 

    <ImageView 
     android:src="@drawable/logo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginBottom="24dp"/> 

    <!-- 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:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="textEmailAddress" 
      android:id="@+id/et_email" 
      android:hint="@string/email_str" /> 
    </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:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="textPassword" 
      android:id="@+id/et_contraseña" 
      android:hint="@string/contraseña_str" /> 
    </android.support.design.widget.TextInputLayout> 



    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 

     <android.support.v7.widget.AppCompatButton 
      android:id="@+id/but_iniciar_sesion" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="24dp" 
      android:layout_marginBottom="24dp" 
      android:padding="12dp" 
      android:text="@string/iniciar_sesion_str"/> 

     <android.support.v7.widget.AppCompatButton 
      android:id="@+id/but_crear_cuenta" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="24dp" 
      android:layout_marginBottom="24dp" 
      android:padding="12dp" 
      android:text="@string/crear_cuenta_str"/> 

    </LinearLayout> 

</LinearLayout> 
그것은 나에게이 메시지 오류주고있다

:

android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class android.support.design.widget.TextInputLayout 

확실히 라이브러리 등을 가져와야합니다. gradle 또는 AndroidManifest.xml에 일부 줄을 추가 할 수도 있습니다.

누구나 할 수있는 방법을 알고 있습니까? u'll 청소 및 프로젝트를 다시 시도 할 문제 ".. 팽창 오류"가있는 경우이를 추가 할 수

답변

0

봅니다,

dependencies { 
    compile "com.android.support:appcompat-v7:25.1.0" 
    compile "com.android.support:design:25.1.0" 
} 

그렇지 않으면 해당 지역의 Gradle을에 종속성. 오후 8시 30 분 P.S. 여기

android:theme="@style/Theme.AppCompat" 

사용 예는 다음과 같습니다 종속성을 추가에 관한 위의 답과 함께 대신 활동

+0

나는 그것을했고 나는 여전히 같은 오류 메시지가 나타납니다. 어쨌든 고마워! – Sergio

+0

@Sergio 흠, 안드로이드에 재미있는 기호가 있습니다. id 및 android : 힌트를 사용하여 이름을 변경하려고 시도합니다. –

0

의 AppCompatActivity를 확장해야하는 레이아웃을 사용 활동, 난 당신이 또한 사용 TextInputLayouts의 테마를 설정해야합니다 믿습니다 귀하의 코드 :

<!-- 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" 
    android:theme="@style/Theme.AppCompat"> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textEmailAddress" 
     android:id="@+id/et_email" 
     android:hint="@string/email_str" /> 
</android.support.design.widget.TextInputLayout>