一、基础使用
-
添加依赖
在
build.gradle中引入 Material Components 库:dependencies { implementation 'com.google.android.material:material:1.11.0' // 使用最新版本 } -
布局配置
用
TextInputLayout包裹TextInputEditText(推荐)或EditText:<com.google.android.material.textfield.TextInputLayout android:id="@+id/username_layout" android:layout_width="match_parent" android:layout_height="wrap_content" app:hint="用户名"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text"/> </com.google.android.material.textfield.TextInputLayout>

最低0.47元/天 解锁文章
6026

被折叠的 条评论
为什么被折叠?



