Properties of shape in the Android XML resource file:
Solid
Description: Internal padding
Properties: Android:color Fill Color
Size
Description: Size
Property:
Android:width width
Android:height High
Gradient
Description: Gradient Color
Property:
Android:startcolor Gradient Start Color
Android:endcolor Gradient End Color
Android:centercolor Gradient Middle Color
Android:angle the gradient angle, when angle=0, the gradient is left to right, then counterclockwise, and when angle=90, the gradient moves from the top down. Angle must be a multiple of 45.
Android:type Gradient Type: linear (linear), radial (radioactive, centered on start color), sweep (scanline gradient)
Android:userlevel set to True if you want to use the Levellistdrawable object. Set true no gradient color, false has gradient
Android:grdientradial gradient radius, this value only takes effect if the type is set to radial
Android:centerx the relative position of the X-point coordinates of the gradient center
Android:centery relative position of y-point coordinates of the gradient center
Stroke
Description: Stroke
Property:
Android:width Stroke width
Android:color Stroke Color
Android:dashwidth stroke style is a dashed width, a value of 0 is solid, and a value greater than 0 is a dashed line
Android:dashgap the distance between dashes when the stroke is dashed
Corners
Description: Rounded Corners
Property:
Android:radius Four Corner radius value
Android:topleftradius the upper left corner radius value
Android:toprightradius the upper right corner radius value
Android:bottomleftradius the lower right corner radius value
Android:bottomrightradius lower left corner radius value
Padding
Description: Inner margin
Property:
Android:left left inner margin
Android:right right inner margin
Android:top on the inside margin
Android:bottom lower inner margin
Report
///////////////////////////////////////////////////
And then, in the activity, use it directly.
Resources Res =getresources ();
String[] City=res.getstringarray (r.array.city);
////////////////////////////////////////////////////
Displaymetrics dm=new displaymetrics ();
Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM);
String strpm=dm.widthpixels+ "*" +dm.heightpixels;//get resolution
/*display Display=getwindowmanager (). Getdefaultdisplay ();
Point Size=new Point ()//Get screen length width
Display.getsize (size); */
///////////////////////////////////////////////////////////
Transparency calculation
AA (the first two bits of the STARTCOLORSTR) is the hexadecimal that represents the opacity, 00 is completely transparent, the FF is all opaque, the decimal range is 0~255, and the remaining rrggbb is the hexadecimal code of the color. How to convert 30% opacity to 16? Very simply, calculate #aa's Decimal x,x/255 = 3/10, solve the X=3*255/10, and then convert the X into 16, approximately equal to 4 B.
/////////////////////////////////////////////////////////////////
Customize dialog box
Dialog dialog=new Dialog (this,r.style.dialog);
View view=getlayoutinflater (). Inflate (r.layout.classroom_info, NULL);
TextView txtjsname= (TextView) View.findviewbyid (r.id.txt_jsname);
TextView txtsitecount= (TextView) View.findviewbyid (R.id.txt_sitecount);
TextView txtholdcount= (TextView) View.findviewbyid (R.id.txt_holdcount);
TextView txtsiteleft= (TextView) View.findviewbyid (r.id.txt_siteleft);
Txtjsname.settext ("Teaching Building 101");
Txtsitecount.settext (21+ "");
Txtholdcount.settext (7+ "");
Txtsiteleft.settext ((21-7) + "");
Dialog.setcontentview (view);
Dialog.setcanceledontouchoutside (TRUE);
Dialog.show ();
dialog box style
<style name= "Dialog" parent= "@android: Style/theme.dialog" >
<item name= "Android:windowframe" > @null </item><!--border--
<item name= "android:windowisfloating" >true</item>< whether the!--appears above activity--
<item name= "android:windowistranslucent" >false</item><!--Translucent--
<item name= "Android:windownotitle" >true</item><!--Untitled--
<!--<item name= "Android:windowbackground" > @color/alpha_bg</item> Background Transparent--
<item name= "android:backgrounddimenabled" >false</item><!--Blur--
</style>
////////////////////////////////////////////////////////////////////
Text Marquee Effect
<textview android:layout_width= "100px"
android:layout_height= "Wrap_content"
Android:textcolor= "@android: Color/white"
Android:ellipsize= "Marquee"
Android:focusable= "true"
android:marqueerepeatlimit= "Marquee_forever"
Android:focusableintouchmode= "true"
Android:scrollhorizontally= "true"
Android:text= "This is the real word marquee effect"
>
</TextView>
Properties of the Android custom shape