我想創造一個美好的佈局,我發現了一個例子,但它不工作:如何開始與材料設計
<?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中添加一些行
有誰知道該怎麼做?
我做到了,而且我仍然收到相同的錯誤消息。不管怎麼說,還是要謝謝你! – Sergio
@Sergio嗯,我在android:id和android:hint中看到一個有趣的符號,試着重命名它們 –