圆角矩形背景editext在背景边框的左上角带有提示

圆角矩形背景editext在背景边框的左上角带有提示,第1张

概述我陷入了创建UI的困境.请帮我创造那个.我有一个具有圆形矩形边框的EditText,可以,但是占位符位于边框的顶部,离开边框.这是图片提前致谢.解决方法:您必须根据需要使用VectorDrawable创建自定义形状.我已经为它创建了一个示例.在res/drawable/下创建custom_vector.xml文件

我陷入了创建UI的困境.请帮我创造那个.

我有一个具有圆形矩形边框的EditText,可以,但是占位符位于边框的顶部,离开边框.

这是图片

提前致谢.

解决方法:

您必须根据需要使用Vector Drawable创建自定义形状.

我已经为它创建了一个示例.
在res / drawable /下创建custom_vector.xml文件

<vector xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:height="20dp"    androID:wIDth="20dp"    androID:vIEwportWIDth="400"    androID:vIEwportHeight="400">    <group        androID:pivotX="10.0"        androID:pivotY="10.0">        <!-- the outsIDe Box -->        <!-- top line & top left corner -->        <path androID:pathData="M 30 60 H 40 c -40 0 -35 0 -35 35 "            androID:strokecolor="#000000" androID:strokeWIDth="10" />        <!-- left line & bottom left corner -->        <path androID:pathData="M 5 64 v 271 c 0 40 0 35 35 35 "            androID:strokecolor="#000000" androID:strokeWIDth="10" />        <!-- bottom line & bottom right corner -->        <path androID:pathData="M 30 370 h 330 c 40 0 35 -10 35 -35"            androID:strokecolor="#000000" androID:strokeWIDth="10" />        <!-- right line & top right corner -->        <path androID:pathData="M 395 356 v -261 c0 -40 0 -35 -50 -35"            androID:strokecolor="#000000" androID:strokeWIDth="10" />        <!-- top line till end-->        <!-- 140 is the starting point of line after TEXT-->        <path androID:pathData="M 140 60 370 60"            androID:strokecolor="#000000" androID:strokeWIDth="10" />    </group></vector>

您可能需要更改最后一个路径标签的值

top line till end

根据您在“名称”位置的文字.您也可以根据需要修改形状或拐角.

在res / layout /下创建一个test_layout.xml文件

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:orIEntation="vertical"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:background="#faffd5">    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:background="@drawable/custom_vector"        androID:layout_margin="20dp"        androID:orIEntation="vertical">        <TextVIEw            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_marginleft="40dp"            androID:paddingleft="5dp"            androID:textSize="20sp"            androID:paddingRight="5dp"            androID:text="name"/>        <EditText            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:layout_marginleft="40dp"            androID:layout_marginRight="20dp"            androID:layout_marginBottom="15dp"            androID:textSize="25sp"            androID:background="@androID:color/transparent"            androID:text="Alex Smith"/>    </linearLayout></linearLayout>

看起来像这个截图

总结

以上是内存溢出为你收集整理的圆角矩形背景editext在背景边框的左上角带有提示全部内容,希望文章能够帮你解决圆角矩形背景editext在背景边框的左上角带有提示所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1095712.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存