Rounded Rectangle "Roundrectshape" use detailed

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.