圆角矩形“RoundRectShape”使用详解
来源:互联网 发布:一部教室的网络喜剧 编辑:程序博客网 时间:2024/06/04 19:21
圆角矩形 常用作一些组件的背景
构造函数:
RoundRectShape(float[] outerRadii, RectF inset, float[] innerRadii)
Specifies an outer (round)rect and an optional inner (round)rect.// 指定一个外部(圆角)矩形 和 一个 可选的 内部(圆角)矩形。
Parameters:
outerRadii
An array of 8 radius values, for the outer roundrect. The first two floats are for the top-left corner (remaining pairs correspond clockwise). For no rounded corners on the outer rectangle, pass null.
//一个包含8个弧度值,指定外部圆角矩形的 4个角部的弧度及 :new float[] {l, l, t, t, r, r, b, b};
// 前2个 左上角, 3 4 , 右上角, 56, 右下, 78 ,左下,如果没弧度的话,传入null即可。
inset
A RectF that specifies the distance from the inner rect to each side of the outer rect. For no inner, pass null.
//指定外部矩形4条边 与内部矩形的4条边的个距离,也用RectF的方式指定。
innerRadii
An array of 8 radius values, for the inner roundrect. The first two floats are for the top-left corner (remaining pairs correspond clockwise). For no rounded corners onthe inner rectangle, pass null. If inset parameter is null, this parameter is ignored.
//同第一个参数。
例子如下:
package com.example.testroundrectshape;import android.app.Activity;import android.graphics.Color;import android.graphics.Paint;import android.graphics.RectF;import android.graphics.drawable.ShapeDrawable;import android.graphics.drawable.shapes.RoundRectShape;import android.os.Bundle;import android.view.Menu;import android.widget.TextView;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);TextView test = (TextView) findViewById(R.id.test);// 外部矩形弧度float[] outerR = new float[] { 8, 8, 8, 8, 8, 8, 8, 8 };// 内部矩形与外部矩形的距离RectF inset = new RectF(100, 100, 50, 50);// 内部矩形弧度float[] innerRadii = new float[] { 20, 20, 20, 20, 20, 20, 20, 20 };RoundRectShape rr = new RoundRectShape(outerR, inset, null);ShapeDrawable drawable = new ShapeDrawable(rr);//指定填充颜色drawable.getPaint().setColor(Color.YELLOW);// 指定填充模式drawable.getPaint().setStyle(Paint.Style.FILL);test.setBackgroundDrawable(drawable);}}
效果图:
- 圆角矩形“RoundRectShape”使用详解
- 圆角矩形“RoundRectShape”使用详解
- 使用layer-list绘制圆角矩形
- Android使用Drawable实现圆角矩形
- android 使用shape自定义圆角矩形
- AWT构造矩形,圆角矩形,3D矩形
- 使用Graphic画圆角矩形和填充圆角矩形的方法
- <<数学>>圆角矩形,矩形重叠(一)
- 把一个矩形变成圆角矩形
- flex sprite圆角矩形发光体的使用
- 使用Canvas和Paint制作圆角矩形头像
- 圆角矩形delphi
- 圆角矩形
- 圆角矩形
- CSS 圆角矩形
- CSS圆角矩形
- 圆角矩形
- html圆角矩形
- AOP和IOC
- 《深入理解java虚拟机》学习笔记5——Java Class类文件结构
- 一转眼13年 马踏14间
- MyEclipse导入,导出 工程
- Android 屏幕亮度调节(2.0以后出现亮度自动调节)如何开启、关闭亮度自动调节
- 圆角矩形“RoundRectShape”使用详解
- mysql source 命令 读取sql
- Win7 wifi热点
- 关于Java的ClassPath
- Android裁剪图片为圆形图片
- 【Objective-C】07-自定义构造方法和description方法
- StreamSocket确实好用!
- java 根据开始日期 ,需要的工作日天数 ,计算工作截止日期,并返回截止日期
- ruby中的Proc类的理解