经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 移动开发 » Android » 查看文章
android shape实现阴影或模糊边效果
来源:cnblogs  作者:安卓笔记侠  时间:2019/10/12 9:04:37  对本文有异议

1.实现阴影或模糊边效果方式:

 

 

2.通过shape来实现,具体是通过layer-list 多层叠放的方式实现的

  1. 1 <?xml version="1.0" encoding="utf-8"?>
  2. 2 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  3. 3 <!-- -->
  4. 4 <item>
  5. 5 <shape android:shape="rectangle">
  6. 6 <padding
  7. 7 android:bottom="2dp"
  8. 8 android:left="2dp"
  9. 9 android:right="2dp"
  10. 10 android:top="2dp" />
  11. 11 <solid android:color="#00CCCCCC" />
  12. 12 <corners android:radius="8dp" />
  13. 13 </shape>
  14. 14 </item>
  15. 15 <item>
  16. 16 <shape android:shape="rectangle">
  17. 17 <padding
  18. 18 android:bottom="2dp"
  19. 19 android:left="2dp"
  20. 20 android:right="2dp"
  21. 21 android:top="2dp" />
  22. 22 <solid android:color="#10CCCCCC" />
  23. 23 <corners android:radius="8dp" />
  24. 24 </shape>
  25. 25 </item>
  26. 26 <item>
  27. 27 <shape android:shape="rectangle">
  28. 28 <padding
  29. 29 android:bottom="2dp"
  30. 30 android:left="2dp"
  31. 31 android:right="2dp"
  32. 32 android:top="2dp" />
  33. 33 <solid android:color="#20CCCCCC" />
  34. 34 <corners android:radius="8dp" />
  35. 35 </shape>
  36. 36 </item>
  37. 37 <item>
  38. 38 <shape android:shape="rectangle">
  39. 39 <padding
  40. 40 android:bottom="2dp"
  41. 41 android:left="2dp"
  42. 42 android:right="2dp"
  43. 43 android:top="2dp" />
  44. 44 <solid android:color="#30CCCCCC" />
  45. 45 <corners android:radius="8dp" />
  46. 46 </shape>
  47. 47 </item>
  48. 48 <item>
  49. 49 <shape android:shape="rectangle">
  50. 50 <padding
  51. 51 android:bottom="2dp"
  52. 52 android:left="2dp"
  53. 53 android:right="2dp"
  54. 54 android:top="2dp" />
  55. 55 <solid android:color="#50CCCCCC" />
  56. 56 <corners android:radius="8dp" />
  57. 57 </shape>
  58. 58 </item>
  59. 59
  60. 60 <!-- 中心背景 -->
  61. 61 <item>
  62. 62 <shape android:shape="rectangle"
  63. 63 android:useLevel="false">
  64. 64 <!-- 实心 -->
  65. 65 <solid android:color="#ffffff" />
  66. 66 <corners android:radius="10dp" />
  67. 67 <padding android:left="10dp"
  68. 68 android:right="10dp"
  69. 69 android:top="10dp"
  70. 70 android:bottom="10dp"/>
  71. 71 </shape>
  72. 72 </item>
  73. 73 </layer-list>

使用:

  1. android:background="@drawable/layer_white_bg"

 顶部缩放了:android:top=2*5=10dp

原文链接:http://www.cnblogs.com/ganchuanpu/p/11655031.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号