zoukankan      html  css  js  c++  java
  • 自定义shape文件

    1、shape文件 btn_bg.xml文件内容
    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、在布局里引用

    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、效果






  • 相关阅读:
    剑指offer14-链表中倒数第k个结点
    剑指offer15-翻转链表
    Matlab矩阵操作
    CUDA线程
    CUDA编程前言
    ROS常用工具
    ROS理解参数服务器param demo
    ROS手动编写服务端和客户端service demo(C++)
    ROS手动编写消息发布器和订阅器topic demo(C++)
    ROS参数服务器(Parameter Server)
  • 原文地址:https://www.cnblogs.com/liupengcheng/p/5685498.html
Copyright © 2011-2022 走看看