Android中的Drawable资源—— GradientDrawable
来源:互联网 发布:c4世嘉轮毂数据 编辑:程序博客网 时间:2024/05/10 01:06
ShapeDrawable 根据原始的形状来绘制图形,如矩形,圆形,线条等,可以是一个纯色的色块,也可以渐变的效果。当没有设置具体的图形时,默认为矩形。
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape=["rectangle" | "oval" | "line" | "ring"] > <corners android:radius="integer" android:topLeftRadius="integer" android:topRightRadius="integer" android:bottomLeftRadius="integer" android:bottomRightRadius="integer" /> <gradient android:angle="integer" android:centerX="float" android:centerY="float" android:centerColor="integer" android:endColor="color" android:gradientRadius="integer" android:startColor="color" android:type=["linear" | "radial" | "sweep"] android:useLevel=["true" | "false"] /> <padding android:left="integer" android:top="integer" android:right="integer" android:bottom="integer" /> <size android:width="integer" android:height="integer" /> <solid android:color="color" /> <stroke android:width="integer" android:color="color" android:dashWidth="integer" android:dashGap="integer" /></shape>
它对应的是一个GradientDrawable对象。
例如:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:angle="45"/> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="8dp" /></shape>
<TextView android:background="@drawable/gradient_box" android:layout_height="wrap_content" android:layout_width="wrap_content" />
Resources res = getResources();Drawable shape = res. getDrawable(R.drawable.gradient_box);TextView tv = (TextView)findViewByID(R.id.textview);tv.setBackground(shape);
0 0
- Android中的Drawable资源—— GradientDrawable
- Android Drawable之GradientDrawable
- Android中的Drawable资源——Transition Drawable
- Android中的Drawable资源——Bitmap
- Android中的Drawable资源—— NinePatchDrawable
- Android中的Drawable资源—— LayerDrawable
- Android中的Drawable资源—— StateListDrawable
- Android中的Drawable资源—— LevelListDrawable
- Android中的Drawable资源—— InsetDrawable
- Android中的Drawable资源—— ClipDrawable
- Android中的Drawable资源—— ScaleDrawable
- Android中的Drawable资源—— VectorDrawable
- Android中的Drawable资源
- Android中的Drawable资源
- Android中的Drawable资源
- Android 中的Drawable资源
- Android中的Drawable资源
- Android中的Drawable资源
- SQL中MAX()和MIN()函数的使用
- 微软编辑器的代码高亮 (恶心模拟)
- 深入理解二维数组
- win7 vs2012/2013 编译boost 1.59
- 核心统一过程EssUP——目的和定义(如何更好的规范软件研发过程)
- Android中的Drawable资源—— GradientDrawable
- MySQL密码修改的方法
- java的一些知识(九)
- 用DOM4j解析xml文件
- Object类源码解析
- IOS Dev Intro - Grand Central Dispatch of Thread Series
- 安装和配置 Oozie
- [leetcode] 190. Reverse Bits
- 我所认识的PHP(二)