Material Design 中的大纲编辑文本 [英] Outlined Edit Text from Material Design

查看:25
本文介绍了Material Design 中的大纲编辑文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何实现带轮廓的文本字段(如

How can I implement an outlined text field (as shown on this material design page)?

推荐答案

阅读 大纲框 .

大纲文本字段具有描边边框并且不太强调.到使用大纲文本字段,将以下样式应用于您的文本输入布局:

Outline text fields have a stroked border and are less emphasized. To use an outline text field, apply the following style to your TextInputLayout:

 style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"

依赖

implementation 'com.android.support:design:28.0.0-alpha1' 

XML

   <android.support.design.widget.TextInputLayout
   android:id="@+id/name_text_input"
   style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   >

   <android.support.design.widget.TextInputEditText
       android:id="@+id/name_edit_text"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:hint="@string/label_name" />
</android.support.design.widget.TextInputLayout>

DEMO

旧版支持在 Android 28 中结束.现在继续使用

Legacy support ended in Android 28 . Now onward use

implementation 'com.google.android.material:material:1.3.0'

这篇关于Material Design 中的大纲编辑文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆