向按钮添加彩色阴影

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

我需要使用"from zelplin"这些属性为按钮添加阴影:

I need to add a shadow to a Button with these attributes "from zelplin":

这是设计

我尝试了这段代码

<Button android:id="@+id/btn_sign_in" android:layout_width="match_parent" android:layout_height="48dp" android:layout_marginTop="35dp" android:background="@drawable/auth_button_shape" android:shadowColor="#41ff4800" android:shadowDx="0" android:shadowDy="8" android:text="@string/sign_in" android:textAllCaps="true" android:textColor="@android:color/white" android:textSize="14sp" />

auth_button_shape

auth_button_shape

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="schemas.android/apk/res/android" android:shape="rectangle"> <solid android:color="#ff7c44" /> <corners android:radius="100dp" /> </shape>

但不起作用,其他属性模糊"和传播"如何为按钮设置它们.

But not worked and the other attributes "Blur" and "Spread" How I can set them for the button.

谢谢.

推荐答案

bg_test.xml :

bg_test.xml :

<layer-list xmlns:android="schemas.android/apk/res/android"> <!--the shadow comes from here--> <item android:bottom="-6dp" android:drawable="@android:drawable/dialog_holo_light_frame" android:left="-6dp" android:right="-6dp" android:top="-6dp"> </item> <item android:bottom="-6dp" android:left="-6dp" android:right="-6dp" android:top="-6dp"> <shape android:shape="rectangle"> <solid android:color="@color/white" /> <stroke android:width="@dimen/_1sdp" android:color="@color/yellow"/> </shape> </item>

Activity.xml 代码:

Activity.xml code:

<Button android:layout_width="@dimen/_150sdp" android:layout_height="48dp" android:layout_marginTop="10dp" android:text="@string/sign_In" android:layout_marginLeft="@dimen/_80sdp" android:layout_gravity="center" android:textSize="14sp" android:background="@drawable/bg_test" />

设计按钮:

更多推荐

向按钮添加彩色阴影

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

发布评论

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

>www.elefans.com

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