Android中的shape使用笔记和阴影的编码

我的简书:https://www.jianshu.com/u/c91e642c4d90
我的CSDN:http://blog.csdn.net/wo_ha
我的GitHub:https://github.com/chuanqiLjp
我的个人博客:https://chuanqiljp.github.io/

版权声明:商业转载请联系我获得授权,非商业转载请在醒目位置注明出处。

1.标签shape

        

2. shape 标签下的gradient 标签

            --
               gradient  渐变色
               android:startColor  颜色值          起始颜色
               android:endColor    颜色值          结束颜色
               android:centerColor 整型           渐变中间颜色,即开始颜色与结束颜色之间的颜色
               android:angle       整型           渐变角度(PS:当angle=0时,渐变色是从左向右。 然后逆时针方向转,当angle=90时为从下往上。
                                                angle必须为45的整数倍)
               android:type        ["linear" | "radial" | "sweep"] 渐变类型(取值:linear、radial、sweep)
                                   linear 线性渐变,这是默认设置
                                   radial 放射性渐变,以开始色为中心。
                                   sweep 扫描线式的渐变。
              android:useLevel   ["true" | "false"] 如果要使用LevelListDrawable对象,就要设置为true。设置为true无渐变。false有渐变色
              android:gradientRadius 整型          渐变色半径.当 android:type="radial" 时才使用。单独使用 android:type="radial"会报错。
              android:centerX      整型            渐变中心X点坐标的相对位置
              android:centerY      整型            渐变中心Y点坐标的相对位置
           -->

3. shape 标签下的solid 标签

            

4. shape 标签下的corners 标签

            

5. shape 标签下的padding 标签

            

6. shape 标签下的size 标签

            

7. shape 标签下的stroke 标签

            

8.使用layer-list(图集)制作控件或布局的阴影

1.在drawable文件夹下创建xml文件并编码


<layer-list xmlns:android="http://schemas.android.com/apk/res/android">


    
    

    <item
        android:bottom="0dp"
        android:left="0dp"
        android:right="0dp"
        android:top="0dp">
        <shape android:shape="rectangle">

            
            <gradient
                android:angle="270"
                android:centerColor="#4A9c9ca0"
                android:centerX="50%"
                android:centerY="50%"
                android:endColor="#4A9c9ca0"
                android:startColor="#0F000000"
                android:type="linear"/>

            <corners
                android:bottomLeftRadius="15dp"
                android:bottomRightRadius="15dp"
                android:topLeftRadius="15dp"
                android:topRightRadius="15dp"/>
        shape>
    item>
    
    
    <item
        android:bottom="3dp"
        android:left="3dp"
        android:right="3dp"
        android:top="3dp">
        <shape android:shape="rectangle">

            <gradient
                android:angle="0"
                android:endColor="#FFf"
                android:startColor="#FFf"/>

            <corners
                android:bottomLeftRadius="10dp"
                android:bottomRightRadius="10dp"
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp"/>
        shape>
    item>
layer-list>

2. 使用时直接设置该文件为背景即可,

android:background="@drawable/img_bg_shadow"

来一个效果图
Android中的shape使用笔记和阴影的编码_第1张图片

你可能感兴趣的:(笔记)