InputTextLayout 属于design包,是一个容器,容器中只能放置一个元素,这和ScroollView类似;不同的是,InputtextLayout里面只能放置EditText;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context="com.example.inputtextlayouttest.MainActivity">
<android.support.design.widget.TextInputLayout
android:id="@+id/til_one"
android:layout_width="match_parent"
app:hintAnimationEnabled="true"
app:errorEnabled="true"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入用户名"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/til_two"
android:layout_marginTop="300dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>