首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在android应用程序中实现带标签文本的勾勒文本字段输入

在android应用程序中实现带标签文本的勾勒文本字段输入
EN

Stack Overflow用户
提问于 2018-05-24 03:51:31
回答 5查看 10.2K关注 0票数 4

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

但是,这就是我的结果

我的代码是:

roundview.xml。

代码语言:javascript
运行
复制
  <?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>
代码语言:javascript
运行
复制
<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

EN

回答 5

Stack Overflow用户

发布于 2018-10-10 19:21:19

这可以通过在TextInputLayout.上应用Widget.MaterialComponents.TextInputLayout.OutlinedBox样式来完成

代码语言:javascript
运行
复制
<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.

票数 8
EN

Stack Overflow用户

发布于 2019-01-09 18:32:36

大纲框

大纲文本字段具有带描边的边框,不太强调。要使用大纲文本字段,请将以下样式应用于TextInputLayout:

代码语言:javascript
运行
复制
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"

参考:TextInputLayout

票数 1
EN

Stack Overflow用户

发布于 2018-05-24 07:07:13

这是使用android.support.design.widget.TextInputLayout.无法实现的您将必须创建一个自定义类,它可以在您的编辑文本周围绘制这种边框,记住提示文本,如果提示文本是常量,则可以使用png作为背景

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50496426

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档