如何使用框制作文本输入布局?

1 android textview android-textinputlayout

像这样: 在此处输入图片说明

这些词email or phone是获得关注时跃升至最高位置的提示。我试图寻找一个图书馆,甚至调查文本输入布局的代码,但不明白如何获得这样的东西???

Ben*_* P. 6

要获得大致的外观,您要做的就是将“大纲”样式应用于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
Run Code Online (Sandbox Code Playgroud)

跳到顶部的“电子邮件或电话”文本是在布局上设置的“提示”文本。

<com.google.android.material.textfield.TextInputLayout
    android:hint="Email or phone"
    ...>
Run Code Online (Sandbox Code Playgroud)

TextInputLayout开发人员指南:https//material.io/develop/android/components/text-input-layout/

您的应用程序中将需要Google Material Components库。入门指南:https//github.com/material-components/material-components-android/blob/master/docs/getting-started.md