android - Material Design 中的大纲编辑文本

标签 android android-layout android-edittext material-design android-textinputlayout

如何实现一个带轮廓的文本字段(如 this material design page 所示)? Activated Edit Text

最佳答案

阅读 Outline Box .

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 中结束。现在继续使用

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

关于android - Material Design 中的大纲编辑文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52401242/

相关文章:

android - 80Mb mp3 文件+40MB 图像,什么是最好的地方? Assets 或原始?eclipse 需要时间来构建?(android 3.0)

android - 显示抽屉导航时明确关注内容

android - ANR keyDispatchingTimedOut 但堆栈跟踪中没有自己的类

android - FragmentContainerView 使用 findNavController

android - 自动完成编辑文本android

java - 从 Java 中的 JSONObject 中提取字符串键值对?

java - 如何读取旋转器并从编辑文本获取数据到 TextView ?

android - App卸载后如何删除文件和文件夹?

android - 如何在我的自定义 styles.xml 中继承默认的 Android 样式?

安卓 : EditText with custom keyboard