You cannot use the style file to format dialog because of project requirements. This can worry about the baby, in the internet search for a bit, basically is the use of style file settings.
1. Setting the default background of dialog
Normally the dialog has a window-level background, which is the black shadow background around the dialog we usually encounter. Using code:
This.getwindow (). Setbackgrounddrawableresource (r.drawable.bg_text_bounced); This.getwindow (). Setbackgrounddrawable (drawable);
is generally set to rounded corners, so I cut a fillet background picture is good, this refers to the dialog, do not get the context of GetWindow, this window set or no effect, so must be in the dialog window set background
Dialog.getwindow (). Setbackgrounddrawableresource (r.drawable.bg_text_bounced);d Ialog.getwindow (). Setbackgrounddrawable (drawable);
2. Other property settings
Setting does not display the dialog box title bar
requestwindowfeature (Window. Feature_no_title );
Go to the Shadows
GetWindow (). Clearflags (Windowmanager.layoutparams. Flag_dim_behind );
Set background
GetWindow (). Setbackgrounddrawableresource (r.drawable. vip_p );
Content Transparency
Windowmanager.layoutparams wmparams =getwindow (). GetAttributes ();
Wmparams.format = pixelformat.transparent; Content is fully transparent
wmparams. format =pixelformat. translucent //content translucent
Wmparams. Alpha =1.0f; //Adjust transparency, 1.0 max
Dialog setting various properties
GetWindow (). SetAttributes (Wmparams);
3, temporarily first think up above two, then think up and then continue to add
This article is from the "Vivian Son" blog, please be sure to keep this source http://9550674.blog.51cto.com/9540674/1891849
Android uses code to set dialog style