1. solid
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <!--绿色填充-->    <solid android:color="#0f0" /></shape>

2.corner

<shape xmlns:android="http://schemas.android.com/apk/res/android" >    <solid android:color="#0f0" />    <!--半径为10px的圆角-->    <corners android:radius="10px" /></shape>

3.gradient

<shape xmlns:android="http://schemas.android.com/apk/res/android" >    <solid android:color="#0f0" />    <corners android:radius="10px" />     <!--渐变色:开始的颜色,中间的颜色,结束的颜色-->    <gradient  android:startColor="#D8FC83" android:centerColor="#41F114" android:endColor="#0f0" /></shape>

4.stroke

<shape xmlns:android="http://schemas.android.com/apk/res/android" >    <solid android:color="#0f0" />    <corners android:radius="10px" />    <gradient  android:centerColor="#41F114" android:endColor="#0f0" android:startColor="#D8FC83" />    <!--边框:宽度,颜色-->    <stroke  android:width="1px" android:color="#f0f" /></shape>

5.阴影效果

需要3个图层:a:最底层和整体背景颜色一致b:中间层left和top错开2dpc:最上层和阴影颜色一致的边框,和最底层一样颜色的填充色,bottom和right方向错开2dp<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" >    <!--最底层-->    <item>        <shape>            <solid android:color="#fff" />        </shape>    </item>  <!--中间层-->    <item  android:left="2dp" android:top="2dp">        <shape>            <solid android:color="#ccc" />        </shape>    </item>  <!--最上层-->    <item  android:bottom="2dp" android:right="2dp">        <shape>            <solid android:color="#fff" />            <stroke  android:width="1px" android:color="#ccc" />        </shape>    </item></layer-list>

6.底部边框颜色和其它边框颜色不同。
–>–>

a:最底层黄色填充色。b:中间层灰色边框1px,白色填充色,bottom 5px,可以露出5px的底层的黄色。c:最上层left,right,top透明边框1px,白色填充色,正好显示出中间层的left,right,top边框。bottom 4px正好覆盖中间层的底部边框。<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" ><!--第一层-->    <item>        <shape>            <solid android:color="#ff0" />        </shape>    </item><!--第二层-->    <item android:bottom="5px">        <shape>            <solid android:color="#fff" />            <stroke  android:width="1px" android:color="#ccc" />        </shape>    </item>为了去掉底部灰色边框,再覆盖一个图层。(白色背景,透明边框,和第二层边框的width基本一致,但bottom的值一定要小于第二层的bottom值)<!--第三层-->    <item  android:bottom="4px" android:left="1px" android:right="1px" android:top="1px">        <shape>            <solid android:color="#fff" />            <stroke  android:width="1px" android:color="#0000" />        </shape>    </item></layer-list>

更多相关文章

  1. Android(安卓)Paint绘制边框注意事项
  2. RichTextUtil Android(安卓)文字高亮可点击工具类分享和示例
  3. android:shape妙用
  4. Android状态栏透明方法,与工具栏颜色一致
  5. Android(安卓)ApiDemos示例解析(77):Graphics->RoundRects
  6. android TextView 改变边框
  7. Android(安卓)生成随机颜色值
  8. Android(安卓)Material Design 之 TextInputLayout
  9. Android(安卓)TextView的设置

随机推荐

  1. Android学习之键盘事件
  2. MyBaseAdapter
  3. Android(安卓)Studio默认产生Fragment
  4. 百度地图API学习笔记(四)
  5. android中有这么些个SystemService,挨个儿
  6. AudioTrack&AudioFlinger
  7. Android模拟强制下线通知功能实例代码
  8. [Android]什么是OOB(Opaque binary blob)
  9. 一分钟解决Shape分割线及分割线圆角框
  10. android沉浸式状态栏和状态栏字体设置工