Use of Android shape

Source: Internet
Author: User

Use of Android shape

The button inside the layout file is then set as follows:

[Java]View PlainCopy
    1. <button
    2. android:id="@+id/button1"
    3. Android:layout_width="Wrap_content"
    4. android:layout_height="Wrap_content"
    5. android:text="Button1"
    6. android:background="@drawable/buttonstyle"/>




Shape is used for setting shapes, can be used in selector,layout and so on, there are 6 sub-tags, the properties are as follows:

[Java]View PlainCopy
    1. <?xml version="1.0" encoding="Utf-8"?>
    2. <shape xmlns:android="http://schemas.android.com/apk/res/android" >
    3. <!--rounded corners--
    4. <corners
    5. android:radius="9DP"
    6. android:topleftradius="2DP"
    7. android:toprightradius="2DP"
    8. android:bottomleftradius="2DP"
    9. android:bottomrightradius="2DP"/><!--set the fillet radius --
    10. <!--gradients--
    11. <gradient
    12. Android:startcolor="@android: Color/white"
    13. Android:centercolor="@android: Color/black"
    14. Android:endcolor="@android: Color/black"
    15. Android:uselevel="true"
    16. " android:angle="
    17. android:type="Radial"
    18. android:centerx="0"
    19. android:centery="0"
    20. android:gradientradius="/> "
    21. <!--Interval--
    22. <padding
    23. android:left="2DP"
    24. android:top="2DP"
    25. android:right="2DP"
    26. android:bottom="2DP"/><!--every direction--
    27. <!--size-
    28. <size
    29. Android:width="50DP"
    30. android:height="50DP"/><!--width and height --
    31. <!---filled
    32. <solid
    33. Android:color="@android: Color/white"/><!--Fill Color--
    34. <!--strokes--
    35. <stroke
    36. Android:width="2DP"
    37. Android:color="@android: Color/black"
    38. Android:dashwidth="1DP"
    39. android:dashgap="2DP"/>
    40. </shape>

Use of Android shape

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.