pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

在 Android Studio 中在 EditText 的所有四個邊上放置陰

Drop shadow around all the four sides of an EditText in Android Studio(在 Android Studio 中在 EditText 的所有四個邊上放置陰影)
本文介紹了在 Android Studio 中在 EditText 的所有四個邊上放置陰影的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

據我所知,沒有任何屬性可以在 EditText 字段周圍放置陰影,可以在布局文件中設置.我搜索了問題并找到了我必須提供自定義背景 xml drawable 的解決方案.

我的 drawable/background_with_shadow 看起來像這樣:

我正在為我的 LinearLayout 設置此屬性,其中包含一個 EditText

但是,它只會在底角和底角周圍投下陰影.我將如何處理所有四個邊和角?

我正在努力實現這一目標:

解決方案

有一些更好的方法可以在不使用 layer-list 的情況下在編輯文本周圍獲得陰影:

#1

將您的 EditText 包裝在 CardView 中,如下所示:

2

使用 9 補丁作為 EditText 的背景:

 <EditTextandroid:id=@+id/msg_box"安卓:填充=20dp";android:background=@dr??awable/shadow"android:layout_width=match_parent"android:layout_height="wrap_content";android:layout_centerVertical=真"安卓:線=5";安卓:重力=頂部";android:hint="輸入您的投訴..."android:textColorHint="#a7a7a7";android:textSize="15dp";/>

輸出

閱讀更多關于 9patch 這里.

這里是一個很棒的在線工具,可以生成 9 個補丁陰影.

As far as my knowledge aids me, there isn't any property to drop shadow around an EditText field, that can be set in the layout file. I searched for the problem and found solution that I've to provide a custom background xml drawable.

My drawable/background_with_shadow looks like this:

<?xml version="1.0" encoding="utf-8"?>
<layer-lis xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape
            android:shape="rectangle">
            <solid android:color="@android:color/darker_gray" />
            <corners android:radius="5dp"/>
        </shape>
    </item>
    <item android:right="1dp" android:left="1dp" android:bottom="2dp">
        <shape
            android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="5dp"/>
        </shape>
    </item>
</layer-list>

and I'm setting this property for my LinearLayout which contains an EditText

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_with_shadow">
<EditText>
.
.
</EditText>
<LinearLayout>

However it just drops the shadow around the bottom and bottom corners. How would I do it for all the four sides and corners?

I'm trying to achieve this:

解決方案

There are some better ways to get shadow around your edit text without using layer-list :

#1

Wrap your EditText in a CardView like this :

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardElevation="7dp"
    android:layout_margin="10dp"
    app:cardCornerRadius="0dp">

        <EditText
            android:id="@+id/msg_box"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:hint="Write a message"
            android:paddingLeft="5dp"
            android:paddingStart="5dp"
            android:textColorHint="#c7c7c7"
            android:textSize="15dp" />

</android.support.v7.widget.CardView>

OUTPUT :

2

Use a 9 patch as the background of your EditText :

    <EditText
        android:id="@+id/msg_box"
        android:padding="20dp"
        android:background="@drawable/shadow"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:lines="5"
        android:gravity="top"
        android:hint="Enter your complaint..."
        android:textColorHint="#a7a7a7"
        android:textSize="15dp" />

OUTPUT

Read more about 9patch here.

Here's a great online tool to generate 9 patch shadow.

這篇關于在 Android Studio 中在 EditText 的所有四個邊上放置陰影的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 生物颗粒燃烧机-生物质燃烧机-热风炉-生物颗粒蒸汽发生器-丽水市久凯能源设备有限公司 | 激光内雕_led玻璃_发光玻璃_内雕玻璃_导光玻璃-石家庄明晨三维科技有限公司 激光内雕-内雕玻璃-发光玻璃 | 智能电表|预付费ic卡水电表|nb智能无线远传载波电表-福建百悦信息科技有限公司 | 顶空进样器-吹扫捕集仪-热脱附仪-二次热解吸仪-北京华盛谱信仪器 | 单级/双级旋片式真空泵厂家,2xz旋片真空泵-浙江台州求精真空泵有限公司 | 伟秀电气有限公司-10kv高低压开关柜-高低压配电柜-中置柜-充气柜-欧式箱变-高压真空断路器厂家 | 清洁设备_洗地机/扫地机厂家_全自动洗地机_橙犀清洁设备官网 | 英思科GTD-3000EX(美国英思科气体检测仪MX4MX6)百科-北京嘉华众信科技有限公司 | 东莞螺杆空压机_永磁变频空压机_节能空压机_空压机工厂批发_深圳螺杆空压机_广州螺杆空压机_东莞空压机_空压机批发_东莞空压机工厂批发_东莞市文颖设备科技有限公司 | 广东健伦体育发展有限公司-体育工程配套及销售运动器材的体育用品服务商 | 郑州大巴车出租|中巴车租赁|旅游大巴租车|包车|郑州旅游大巴车租赁有限公司 | 阿里巴巴诚信通温州、台州、宁波、嘉兴授权渠道商-浙江联欣科技提供阿里会员办理 | 起好名字_取个好名字_好名网免费取好名在线打分 | 智慧物联网行业一站式解决方案提供商-北京东成基业 | 10吨无线拉力计-2吨拉力计价格-上海佳宜电子科技有限公司 | 重庆网站建设,重庆网站设计,重庆网站制作,重庆seo,重庆做网站,重庆seo,重庆公众号运营,重庆小程序开发 | 螺旋绞龙叶片,螺旋输送机厂家,山东螺旋输送机-淄博长江机械制造有限公司 | 3dmax渲染-效果图渲染-影视动画渲染-北京快渲科技有限公司 | NMRV减速机|铝合金减速机|蜗轮蜗杆减速机|NMRV减速机厂家-东莞市台机减速机有限公司 | 贵州水玻璃_-贵阳花溪闽兴水玻璃厂 | 校园文化空间设计-数字化|中医文化空间设计-党建|法治廉政主题文化空间施工-山东锐尚文化传播公司 | 高低温老化试验机-步入式/低温恒温恒湿试验机-百科 | 嘉兴恒升声级计-湖南衡仪声级计-杭州爱华多功能声级计-上海邦沃仪器设备有限公司 | 济南网站建设|济南建网站|济南网站建设公司【济南腾飞网络】【荐】 | 拖链电缆_柔性电缆_伺服电缆_坦克链电缆-深圳市顺电工业电缆有限公司 | vr安全体验馆|交通安全|工地安全|禁毒|消防|安全教育体验馆|安全体验教室-贝森德(深圳)科技 | 球磨机,节能球磨机价格,水泥球磨机厂家,粉煤灰球磨机-吉宏机械制造有限公司 | 螺钉式热电偶_便携式温度传感器_压簧式热电偶|无锡联泰仪表有限公司|首页 | 海德莱电力(HYDELEY)-无功补偿元器件生产厂家-二十年专业从事电力电容器 | 上海律师咨询_上海法律在线咨询免费_找对口律师上策法网-策法网 广东高华家具-公寓床|学生宿舍双层铁床厂家【质保十年】 | 云南成人高考_云南成考网| 花纹铝板,合金铝卷板,阴极铝板-济南恒诚铝业有限公司 | 消电检公司,消电检价格,北京消电检报告-北京设施检测公司-亿杰(北京)消防工程有限公司 | 有源电力滤波装置-电力有源滤波器-低压穿排电流互感器|安科瑞 | 河南中整光饰机械有限公司-抛光机,去毛刺抛光机,精密镜面抛光机,全自动抛光机械设备 | 高尔夫球杆_高尔夫果岭_高尔夫用品-深圳市新高品体育用品有限公司 | TMT观察网_独特视角观察TMT行业 派财经_聚焦数字经济内容服务平台 | 篮球地板厂家_舞台木地板品牌_体育运动地板厂家_凯洁地板 | 法钢特种钢材(上海)有限公司 - 耐磨钢板、高强度钢板销售加工 阀门智能定位器_电液动执行器_气动执行机构-赫尔法流体技术(北京)有限公司 | 丁基胶边来料加工,医用活塞边角料加工,异戊二烯橡胶边来料加工-河北盛唐橡胶制品有限公司 | 南京兰江泵业有限公司-水解酸化池潜水搅拌机-絮凝反应池搅拌机-好氧区潜水推进器 |