Customizing the Shape file

Source: Internet
Author: User

1. Shape file Btn_bg.xml file contents
  
 
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android">
  3. <!--背景颜色-->
  4. <solid android:color="#00CCFF"/>
  5. <!--corners 圆角角度-->
  6. <corners android:radius="300dip"/>
  7. <!--padding参数
  8. 内容距离上下左右的距离
  9. -->
  10. <padding
  11. android:bottom="50dp"
  12. android:left="50dp"
  13. android:right="50dp"
  14. android:top="50dp"/>
  15. <!-- gradient的参数
  16. 1、起始颜色
  17. android:startColor="#00CCFF"
  18. 2、中间颜色
  19. android:centerColor="#00FF00"
  20. 3、结束颜色
  21. android:startColor="#00CCFF"
  22. 4、渐变角度,必须为45的整数倍
  23. android:angle="45"
  24. -->
  25. <gradient
  26. android:startColor="#00CCFF"
  27. android:centerColor="#00FF00"
  28. android:endColor="#FF777777"
  29. android:angle="45"
  30. />
  31. <!-- stroke的参数
  32. 虚线的颜色
  33. android:color="#000007"
  34. 虚线的高度
  35. android:width="1dp"
  36. 虚线之间的距离
  37. android:dashGap="10dp"
  38. 单个虚线的大小
  39. android:dashWidth="10dp"
  40. -->
  41. <stroke
  42. android:color="#000007"
  43. android:width="10dp"
  44. android:dashGap="10dp"
  45. android:dashWidth="10dp"
  46. />
  47. </shape>

2, in the layout of the reference
  
 
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:padding="5dp"
  7. tools:context="lpc.com.volley_demo.MainActivity">
  8. <TextView
  9. android:background="@drawable/btn_bg"
  10. android:text="我是一个粉刷匠"
  11. android:layout_width="match_parent"
  12. android:layout_height="wrap_content" />
  13. </LinearLayout>

3. Effect



From for notes (Wiz)

Customizing the Shape file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.