如何制作带框的文本输入布局?
How to make a text input layout with box?
像这样:
单词email or phone
是获得焦点时跳转到顶部的提示。我尝试搜索一个库,甚至查看文本输入布局的代码,但无法理解如何获得类似的东西???
要获得一般外观,您所要做的就是将 "outline" 样式应用于 TextInputLayout
标签:
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
...>
<com.google.android.material.textfield.TextInputEditText
.../>
</com.google.android.material.textfield.TextInputLayout
跳转到顶部的"Email or phone"文本是布局上设置的"hint"文本。
<com.google.android.material.textfield.TextInputLayout
android:hint="Email or phone"
...>
TextInputLayout 开发人员指南:https://material.io/develop/android/components/text-input-layout/
您的应用程序中需要 Google Material 组件库。入门指南:https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md
像这样:
单词email or phone
是获得焦点时跳转到顶部的提示。我尝试搜索一个库,甚至查看文本输入布局的代码,但无法理解如何获得类似的东西???
要获得一般外观,您所要做的就是将 "outline" 样式应用于 TextInputLayout
标签:
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
...>
<com.google.android.material.textfield.TextInputEditText
.../>
</com.google.android.material.textfield.TextInputLayout
跳转到顶部的"Email or phone"文本是布局上设置的"hint"文本。
<com.google.android.material.textfield.TextInputLayout
android:hint="Email or phone"
...>
TextInputLayout 开发人员指南:https://material.io/develop/android/components/text-input-layout/
您的应用程序中需要 Google Material 组件库。入门指南:https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md