![](/img/trans.png)
[英][Android]How do I dynamically add image buttons on the click of a button?
[英]How do I can add a box show the image I click and eraser
很好,在android xml布局中没有框阴影属性,这就是我们为什么使用边框或笔触的原因,或者您可以在彼此顶部创建2个框并稍加位移以创建阴影外观,使用layer-list这是boxshadow.xml drawable xml文件,保存在res / drawable文件夹中:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
<shape>
<corners android:radius="10dip" />
<gradient
android:angle="0"
android:endColor="#cccccc"
android:startColor="#4c4c4c" />
</shape>
</item>
<item android:bottom="3dp" android:right="3dp" android:left="3dp" android:top="3dp" >
<shape>
<corners android:radius="10dip" />
<gradient
android:angle="270"
android:centerColor="#f8d79b"
android:centerY="0.5"
android:endColor="#f8d79b"
android:startColor="#f8d79b" />
</shape>
</item>
</layer-list>
这只是一个示例,这是此形状的结果:
我将xml文件用作activitylayout.xml中按钮的背景,如下所示:
<Button
android:layout_width="90dp"
android:layout_height="wrap_content"
android:text="Back"
android:id="@+id/button_back"
android:background="@drawable/boxshadow" />
当然,您可以将相同的boxshadow.xml用作任何其他元素(例如TextView,EditText或ImageView)的背景。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.