我想用 float 标签实现这种类型的输入文本布局,但问题是当我运行应用程序时它看起来不一样并且标 checkout 现在输入文本字段的上侧。
但是,这是我的结果
我的代码是:
roundview.xml。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#ffffff"/>
<corners android:radius="10dp" />
<stroke
android:width="2dp"
android:color="#3bbdfa"
/>
</shape>
</item>
</selector>
<android.support.design.widget.TextInputLayout
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="@+id/edittxt"
android:layout_width="match_parent"
android:layout_height="130dp"
android:background="@drawable/roundview"
android:fadeScrollbars="false"
android:fadingEdge="vertical"
android:foregroundGravity="fill_vertical"
android:hint="name"
android:isScrollContainer="false"
android:requiresFadingEdge="vertical"
android:singleLine="false"
android:visibility="visible" />
</android.support.design.widget.TextInputLayout>
我关注 https://material.io/design对于文本字段设计,但我遇到了这个问题。谢谢
最佳答案
这可以通过在 TextInputLayout 上应用
Widget.MaterialComponents.TextInputLayout.OutlinedBox
样式来完成。
<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"
app:errorEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="@+id/name_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name" />
</android.support.design.widget.TextInputLayout>
You can check this answer which also has a link to an example.
关于android - Android 应用程序中带标签文本的实现概述文本字段输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50496426/