public class RoundRectShape
extends RectShape
| java.lang.Object | |||
| android.graphics.drawable.shapes.Shape | |||
| android.graphics.drawable.shapes.RectShape | |||
| android.graphics.drawable.shapes.RoundRectShape | |||
创建一个圆角矩形。 或者,可以包含一个插入(圆角)的矩形(以形成一种“O”形状)。 圆角矩形可以用自己的draw()方法绘制到画布上,但如果将RoundRectShape传递给ShapeDrawable则可以使用更多图形控件。
Public constructors |
|
|---|---|
RoundRectShape(float[] outerRadii, RectF inset, float[] innerRadii) RoundRectShape构造函数。 |
|
公共方法(Public methods) |
|
|---|---|
RoundRectShape |
clone() 创建并返回此对象的副本。 |
void |
draw(Canvas canvas, Paint paint) 使用提供的Paint将此形状绘制到提供的Canvas中。 |
void |
getOutline(Outline outline) 计算形状的轮廓并将其返回到提供的大纲参数中。 |
Protected methods |
|
|---|---|
void |
onResize(float w, float h) 执行 |
继承方法(Inherited methods) |
|
|---|---|
android.graphics.drawable.shapes.RectShape
|
|
android.graphics.drawable.shapes.Shape
|
|
java.lang.Object
|
|
RoundRectShape (float[] outerRadii,
RectF inset,
float[] innerRadii)
RoundRectShape构造函数。 指定一个外(圆)矩形和一个可选的内(圆)矩形。
| 参数(Parameters) | |
|---|---|
outerRadii |
float: 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. |
inset |
RectF: A RectF that specifies the distance from the inner rect to each side of the outer rect. For no inner, pass null. |
innerRadii |
float: 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 on the inner rectangle, pass null. If inset parameter is null, this parameter is ignored. |
RoundRectShape clone ()
创建并返回此对象的副本。 “复制”的确切含义可能取决于对象的类别。 一般意图是,对于任何对象x ,表达式:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements. While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
按照惯例,返回的对象应该通过调用super.clone获得。 如果一个类和它的所有超类( Object除外)都遵守这个约定,那将是x.clone().getClass() == x.getClass() 。
按照惯例,这个方法返回的对象应该独立于这个对象(被克隆)。 为了实现这种独立性,可能需要在返回super.clone之前修改返回的对象的一个或多个字段。 通常,这意味着复制包含被克隆对象的内部“深层结构”的任何可变对象,并将这些对象的引用替换为对这些副本的引用。 如果一个类仅包含原始字段或对不可变对象的引用,那么通常情况下不需要修改由super.clone返回的对象中的任何字段。
类Object的方法clone执行特定的克隆操作。 首先,如果该对象的类没有实现接口Cloneable ,则引发CloneNotSupportedException 。 请注意,所有数组都被视为实现接口Cloneable并且数组类型T[]的clone方法的返回类型为T[] ,其中T是任何引用或基本类型。 否则,此方法创建该对象的类的新实例,并使用该对象的相应字段的内容来初始化其所有字段,就像通过赋值一样; 这些字段的内容本身并不克隆。 因此,此方法执行此对象的“浅拷贝”,而不是“深拷贝”操作。
类 Object本身并不实现接口 Cloneable ,所以在类为 Object的对象上调用 clone方法将导致在运行时抛出异常。
| 返回(Returns) | |
|---|---|
RoundRectShape |
a clone of this instance. |
| 抛出异常(Throws) | |
|---|---|
CloneNotSupportedException |
|
void draw (Canvas canvas, Paint paint)
使用提供的Paint将此形状绘制到提供的Canvas中。 在致电之前,您必须致电resize(float, float) 。
| 参数(Parameters) | |
|---|---|
canvas |
Canvas: the Canvas within which this shape should be drawn |
paint |
Paint: the Paint object that defines this shape's characteristics |
void getOutline (Outline outline)
计算形状的轮廓并将其返回到提供的大纲参数中。 默认实现不做任何操作, outline不会更改。
| 参数(Parameters) | |
|---|---|
outline |
Outline: The Outline to be populated with the result. Should not be null. |
void onResize (float w,
float h)
执行 resize(float, float)时 resize(float, float)回调方法。
| 参数(Parameters) | |
|---|---|
w |
float: the new width of the Shape |
h |
float: the new height of the Shape |