TextInputLayout
标记即可:
要获得那种一般的外观,您只需将“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
“电子邮件或电话”文本跳转到顶部是布局上设置的“提示”文本。
<com.google.android.material.textfield.TextInputLayout
android:hint="Email or phone"
...>
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
targetSdkVersion 28
和'com.android.support:design:28.0.0'
库,则可能不需要设计支持库。那么这个TextInputLayout
已经存在于您的应用程序中了。上面的链接是进一步了解的好资源。 - user4831795