zoukankan      html  css  js  c++  java
  • android shape的使用

    shape用于设定形状,可以在selector,layout等里面使用,有6个子标签,各属性如下:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <shape xmlns:android="http://schemas.android.com/apk/res/android" >
     3     
     4     <!-- 圆角 -->
     5     <corners
     6         android:radius="9dp"
     7         android:topLeftRadius="2dp"
     8         android:topRightRadius="2dp"
     9         android:bottomLeftRadius="2dp"
    10         android:bottomRightRadius="2dp"/><!-- 设置圆角半径 -->
    11     
    12     <!-- 渐变 -->
    13     <gradient
    14         android:startColor="@android:color/white"
    15         android:centerColor="@android:color/black"
    16         android:endColor="@android:color/black"
    17         android:useLevel="true"
    18         android:angle="45"
    19         android:type="radial"
    20         android:centerX="0"
    21         android:centerY="0"
    22         android:gradientRadius="90"/>
    23     
    24     <!-- 间隔 -->
    25     <padding
    26         android:left="2dp"
    27         android:top="2dp"
    28         android:right="2dp"
    29         android:bottom="2dp"/><!-- 各方向的间隔 -->
    30     
    31     <!-- 大小 -->
    32     <size
    33         android:width="50dp"
    34         android:height="50dp"/><!-- 宽度和高度 -->
    35     
    36     <!-- 填充 -->
    37     <solid
    38         android:color="@android:color/white"/><!-- 填充的颜色 -->
    39     
    40     <!-- 描边 -->
    41     <stroke
    42         android:width="2dp"
    43         android:color="@android:color/black"
    44         android:dashWidth="1dp"
    45         android:dashGap="2dp"/>
    46     
    47 </shape>

    填充:设置填充的颜色

    间隔:设置四个方向上的间隔

    大小:设置大小

    圆角:同时设置五个属性,则Radius属性无效

    android:Radius="20dp"                           设置四个角的半径

    android:topLeftRadius="20dp"              设置左上角的半径
    android:topRightRadius="20dp"           设置右上角的半径
    android:bottomLeftRadius="20dp"      设置右下角的半径
    android:bottomRightRadius="20dp"    设置左下角的半径

    描边:dashWidth和dashGap属性,只要其中一个设置为0dp,则边框为实现边框

    android:width="20dp"                               设置边边的宽度
    android:color="@android:color/black"  设置边边的颜色
    android:dashWidth="2dp"                         设置虚线的宽度
    android:dashGap="20dp"                          设置虚线的间隔宽度

    渐变:当设置填充颜色后,无渐变效果。angle的值必须是45的倍数(包括0),仅在type="linear"有效,不然会报错。android:useLevel 这个属性不知道有什么用。

    angle对应值的起点如图:

    ps:http://www.cnblogs.com/cyanfei/archive/2012/07/27/2612023.html

  • 相关阅读:
    经典布局 ---- 双飞翼
    细嚼浏览器兼容----条件注释判断浏览器版本
    webqq的注册登记和聊天页面--运用jsonp跨域
    Bootstrap框架的要点--栅格系统
    html5橡皮檫特效
    PHP正确获取客户端IP地址
    常用排序算法及Java实现
    Math类中的floor、ceil和round方法
    Java中的动态反射机制和动态代理
    测试
  • 原文地址:https://www.cnblogs.com/maxinliang/p/3858476.html
Copyright © 2011-2022 走看看