如何实现一个带轮廓的文本字段(如 this material design page 所示)?
最佳答案
阅读 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>
仅供引用
旧版支持在 Android 28 中结束。现在继续使用
implementation 'com.google.android.material:material:1.3.0'
关于android - Material Design 中的大纲编辑文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52401242/