我想用浮动标签实现这种类型的输入文本布局,但问题是当我运行应用程序时,它看起来不一样,并且标签显示在输入文本字段的上方。

但是,这就是我的结果

我的代码是:
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进行文本字段设计,但我得到了这个problem.thanks
发布于 2018-10-10 19:21:19
这可以通过在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.
发布于 2019-01-09 18:32:36
大纲框
大纲文本字段具有带描边的边框,不太强调。要使用大纲文本字段,请将以下样式应用于TextInputLayout:
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"发布于 2018-05-24 07:07:13
这是使用android.support.design.widget.TextInputLayout.无法实现的您将必须创建一个自定义类,它可以在您的编辑文本周围绘制这种边框,记住提示文本,如果提示文本是常量,则可以使用png作为背景
https://stackoverflow.com/questions/50496426
复制相似问题