美文网首页
安卓学习笔记------shape学习

安卓学习笔记------shape学习

作者: 天青色等烟雨hhft | 来源:发表于2017-12-14 19:08 被阅读0次

自从UI知道了安卓可以自己写圆角,边框之类的之后,就很少切图了,而我之前都是copy之前写好的,并不知道里面的某些属性是什么意思,今天学习一下。

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

 <!-- 圆角 -->
    <corners
        android:radius="9dp"
        android:topLeftRadius="2dp"
        android:topRightRadius="2dp"
        android:bottomLeftRadius="2dp"
        android:bottomRightRadius="2dp"/><!-- 设置圆角半径 -->

渐变:当设置填充颜色后,无渐变效果。angle的值必须是45的倍数(包括0),仅在type="linear"有效

    
    <!-- 渐变 -->
    <gradient
        android:startColor="@android:color/white"
        android:centerColor="@android:color/black"
        android:endColor="@android:color/black"
        android:useLevel="true"
        android:angle="45"
        android:type="radial"
        android:centerX="0"
        android:centerY="0"
        android:gradientRadius="90"/>

各方向的间隔

    
    <!-- 间隔 -->
    <padding
        android:left="2dp"
        android:top="2dp"
        android:right="2dp"
        android:bottom="2dp"/>

设置宽高

    
    <!-- 大小 -->
    <size
        android:width="50dp"
        android:height="50dp"/>

设置填充的颜色

    
    <!-- 填充 -->
    <solid
        android:color="@android:color/white"/>

dashWidth="1dp",dashGap="2dp"分别设置虚线的宽度和设置虚线,它们两个中任意一个为0,则边框为实线的

    
    <!-- 描边 -->
    <stroke
        android:width="2dp"
        android:color="@android:color/black"
        android:dashWidth="1dp"
        android:dashGap="2dp"/>

相关文章

网友评论

      本文标题:安卓学习笔记------shape学习

      本文链接:https://www.haomeiwen.com/subject/sggpixtx.html