添加阴影效果的EditText场

编程入门 行业动态 更新时间:2024-10-22 19:23:46
本文介绍了添加阴影效果的EditText场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想设计一个的EditText字段有阴影(底部和右侧)这样

I am trying to design an EditText Field having Shadows (bottom and right side) like this

尝试谷歌搜索和放大器;猎杀多那么讨论,但都是对的TextView不EditText上。

tried googling & hunted many SO discussions but all are for TextView not EditText.

这是我的code添加阴影输入文本而不是文本字段

This is my code adding shadow to Input Text but not to TextField

<EditText android:id="@+id/txtpin" android:maxLength="4" android:layout_marginLeft="10dp" android:layout_height="37dp" android:gravity="center_horizontal" android:inputType="textPassword" android:longClickable="false" android:layout_width="160dp" android:shadowColor="@color/Black" android:shadowDx="1.2" android:shadowDy="1.2" android:shadowRadius="1.5" android:background="@color/White"> <requestFocus></requestFocus> </EditText>

我想这需要在绘制,但没有得到确切的想法的自定义XML视图。 将是什么逻辑来实现这一点。

I guess it needs some custom xml view in drawable but not getting exact idea. What will be the logic to achieve this.

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

嗯.. @ Shalini的回答让我以这种方式,但我仍得到了另一种方式来实现2D影线的EditText场,我会与大家分享。

Well.. @Shalini's answer helped me in this way but still I got another way to achieve 2D shadow with EditText Field and I am going to share with you.

我们需要有三个层的EditText创建自定义XML视图,   底部阴影和右侧的阴影

We need to create custom XML view with three layer for EditText, bottom shadow and right side shadow

下面是我的code。

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="schemas.android/apk/res/android"> <!-- most important is order of layers --> <!-- Bottom right side 2dp Shadow --> <item > <shape android:shape="rectangle"> <solid android:color="#000000" /> </shape> </item> <!-- Bottom 2dp Shadow --> <item> <shape android:shape="rectangle"> <solid android:color="#000000" /> </shape> </item> <!-- White Top color --> <item android:bottom="3px" android:right="3px"> <shape android:shape="rectangle"> <solid android:color="#FFFFFF" /> </shape> </item> </layer-list>

现在我们可以使用这个设置阴影,以我们的文本字段背景属性。

Now we can set this shadow view to our TextField using "Background" property

像这样

<EditText android:layout_width="wrap_content" android:id="@+id/txtpin" android:maxLength="4" android:layout_height="37dp" android:gravity="center_horizontal" android:longClickable="false" android:padding="2dp" android:inputType="textPassword|number" android:password="true" android:background="@drawable/edittext_shadow" android:layout_weight="0.98" android:layout_marginLeft="15dp"> <requestFocus></requestFocus> </EditText>

和结果屏幕就像是我曾经参与过上述问题。

and the result screen is like I have posted in question above.

由于SO,分享知识。

更多推荐

添加阴影效果的EditText场

本文发布于:2023-11-12 03:50:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580432.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阴影   效果   EditText

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!