shape图形的使用

在项目中如果用到有规律的常规的图形,在能够掌握的前提下建议使用shape图形,shape图形相对与图片来说,占用资源更小,并且使用起来不会失真。

效果图

  • shape图形1
    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 主体颜色 填充颜色 -->
<solid android:color="#FF00FFFF" />
<!-- 圆角 -->
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="15dp"
android:topRightRadius="0dp" />
</shape>
  • shape图形2
    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 主体颜色 填充颜色 -->
<solid android:color="#33000000" />
<!-- 圆角 -->
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="0dp"
android:topRightRadius="15dp" />
</shape>
  • shape图形3
    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 渐变颜色 -->
<gradient
android:centerColor="#33000000"
android:endColor="#99000000"
android:startColor="#99000000" />
<!-- 圆角 -->
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="0dp"
android:topRightRadius="15dp" />
</shape>
  • shape图形4
    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 渐变颜色 -->
<solid android:color="#FFFF00FF" />
<!-- 圆角 -->
<corners android:radius="10dp" />
</shape>
  • shape图形5
    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 渐变颜色 -->
<solid android:color="#FFFF00FF" />
<!-- 圆角 -->
<corners android:radius="10dp" /> <stroke
android:width="5dp"
android:color="#FF000000"
android:dashGap="3dp"
android:dashWidth="2dp" />
</shape>

使用

  • 文件存放位置

  • 用法

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape"
android:padding="20dp"
android:text="shape图形1"
android:textSize="20sp" />

Shape图形可以当作是一张图片来使用,和设置背景是一样的用法。

属性介绍

  • solid

    实心,主体

    android:color指定填充的颜色
  • gradient

    渐变

    android:startColor  设置起始颜色
android:centerColor 设置中间颜色
android:endColor 设置结束颜色
  • stroke

    描边

    android:width           描边的宽度
android:color 描边的颜色
android:dashWidth 横线的宽度
android:dashGap 表示之间隔开的距离。
  • corners

    圆角

    android:radius  四个角的弧度

    android:topRightRadius              右上角弧度
android:bottomLeftRadius 左下角弧度
android:topLeftRadius 左上角弧度
android:bottomRightRadius 右下角弧度
  • padding

    间隔

    android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp"

shape图形的使用的更多相关文章

  1. android shape图形优化Button效果

    android shape可以让我们通过定义xml文件的方式创建图形,当然只能实现一些比较简单的图形(圆形,矩形,椭圆,线段),但是已经相当不错了,通过shape创建的图形作为控件的背景已经基本可以满 ...

  2. Android 中 shape 图形的使用

    转载于:http://kofi1122.blog.51cto.com/2815761/521605 Android中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对shap ...

  3. shape 图形

    主要属性: <?xml version="1.0"encoding="utf-8"?><shape > <corners /> ...

  4. 背水一战 Windows 10 (12) - 绘图: Shape, Path

    [源码下载] 背水一战 Windows 10 (12) - 绘图: Shape, Path 作者:webabcd 介绍背水一战 Windows 10 之 绘图 Shape - 图形 Path - 路径 ...

  5. Netron开发快速上手(一):GraphControl,Shape,Connector和Connection

    版权所有,引用请注明出处:<<http://www.cnblogs.com/dragon/p/5203663.html >> 本文所用示例下载FlowChart.zip 一个用 ...

  6. 绘图: Shape, Path

    Shape - 图形 Path - 路径 示例1.演示“Shape”相关知识点Drawing/Shape.xaml <Page x:Class="Windows10.Drawing.S ...

  7. 重新想象 Windows 8 Store Apps (18) - 绘图: Shape, Path, Stroke, Brush

    原文:重新想象 Windows 8 Store Apps (18) - 绘图: Shape, Path, Stroke, Brush [源码下载] 重新想象 Windows 8 Store Apps ...

  8. Android Drawable - Shape Drawable使用详解(附图)

    TIPS shape图形 –简单介绍 shape图形 –如何画? shape图形 –参数详细解析 shape图形 –如何用? shape图形 –实际开发应用场景 shape图形简单介绍 用xml实现一 ...

  9. FlasActionScript3随学随机

    1.跳转页面代码.下载代码(new URLRequest(下载地址)): var request1:URLRequest=new URLRequest("http://www.baidu.c ...

随机推荐

  1. [Codeforces 961G]Partitions

    Description 题库链接 给你 \(n\) 个不同的元素组成的集合 \(R\) ,每个元素有一个权值 \(w\) .对于一个子集集合 \(S\) ,它的价值为 \(W(S)=|S|\cdot\ ...

  2. [AtCoder agc021D]Reversed LCS

    Description 题库链接 在改变原串 \(S\) 最多 \(K\) 个字母的前提下,使得 \(S\) 和 \(S\) 的反串的 \(LCS\) 尽量长,问最长长度. \(1\leq K\leq ...

  3. [HNOI 2017]礼物

    Description 我的室友最近喜欢上了一个可爱的小女生.马上就要到她的生日了,他决定买一对情侣手 环,一个留给自己,一个送给她.每个手环上各有 n 个装饰物,并且每个装饰物都有一定的亮度.但是在 ...

  4. [bzoj4822][Cqoi2017]老C的任务&[bzoj1935][Shoi2007]Tree 园丁的烦恼

    来自FallDream的博客,未经允许,请勿转载,谢谢. 老 C 是个程序员.     最近老 C 从老板那里接到了一个任务——给城市中的手机基站写个管理系统.作为经验丰富的程序员,老 C 轻松地完成 ...

  5. 实现PC视频播放最强画质教程( Potplayer播放器+MADVR插件)【转】

    转自:http://www.hangge.com/blog/cache/detail_1461.html 一.MADVR介绍 MADVR 是一款超强的视频插件,其配合高清播放软件,可以做到目前 PC  ...

  6. Cisco 关闭命令同步提示信息

    Router(config)#no logging console 如果你通过console连接,使用第一条Router(config)#no logging monitor 如果通过telnet,s ...

  7. sqlserver 取日期年份月份

    select convert(varchar(10),datepart(YYYY,a.fssj)) as years,--得到年份convert(varchar(10),datepart(mm,a.f ...

  8. Parallel.For 平行算法 使用

    之前看到Parallel的用法,觉得很高深,很腻害,今天专门抽空研究了一下,发现还是很easy的. .NET Framework 4.0 新加的功能,所以4.0之前的无法使用哦. 下面介绍一下,Par ...

  9. WMI远程启动软件(某个应用程序)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.M ...

  10. Template Method 模板设计模式

    什么是模板设计模式 对于不了解的模板设计模式的来说,可以认为如同古代的造纸术一样,纸所以成型,取决于用了模板的形状,形状又由镂空的木板组成,而你想要造什么纸,又取决于你使用什么材料. 上面提到了两个关 ...