Rounded rectangles are often used as backgrounds for some components
constructor function:
Roundrectshape (float[] outerradii, RECTF inset, float[] innerradii)
Specifies an outer (round) Rect, and an optional inner (round) rect.//Specify an outer (rounded) rectangle and an optional inner (rounded) rectangle.
Parameters:
outerradii
An array of 8 radius values, for the outer roundrect. The first and the floats is for the top-left corner (remaining pairs correspond clockwise). For no rounded corners on the outer
Rectangle, pass null.
An arc containing 8 radians that specifies the 4 corners of the outer rounded rectangle and: New float[] {L, L, T, T, R, R, B, b};
Top 2 upper left corner, 3 4, upper right corner, 56, lower right, 78, lower left, if no radian, pass in null.
inset
A RECTF that specifies the distance from the inner rect to each side of the outer rect. For no inner, pass null.
Specifies the distance between the outer rectangle 4 edges and the 4 edges of the inner rectangle, and is also specified as a RECTF.
innerradii
An array of 8 radius values, for the inner roundrect. The first and the floats is 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.
With the first parameter.
Examples are as follows:
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);//outer rectangle radian float[] outerr = new float[] {8, 8, 8, 8, 8, 8, 8, 8};//internal moments The distance between the shape and the outer rectangle RECTF inset = new RECTF (100, 100, 50, 50);//inner Rectangle radian float[] innerradii = new float[] {20, 20, 20, 20, 20, 20, 20, 20}; Roundrectshape rr = new Roundrectshape (outerr, inset, null); Shapedrawable drawable = new shapedrawable (RR);//Specify Fill Color Drawable.getpaint (). SetColor (Color.yellow);// Specifies the fill mode drawable.getpaint (). SetStyle (Paint.Style.FILL); Test.setbackgrounDdrawable (drawable);}}
:
Rounded Rectangle "Roundrectshape" use detailed