Popupwindow achieves floating translucent Effect

Source: Internet
Author: User

 

If a translucent box is displayed

Java code:

// Clear the data private void showpopup () {layoutinflater mlayoutinflater = (layoutinflater) getsystemservice (layout_inflater_service); viewgroup mview = (viewgroup) mlayoutinflater. inflate (R. layout. soft_calendar_popup, null, true); Final popupwindow = new popupwindow (mview, layoutparams. wrap_content, layoutparams. wrap_content, true); Final radiobutton radio1 = (radiobutton) mview. findviewbyid (R. id. radio0); Final radiobutton Radio2 = (radiobutton) mview. findviewbyid (R. id. radio1); Final radiobutton radio3 = (radiobutton) mview. findviewbyid (R. id. radio2); button btn1 = (button) mview. findviewbyid (R. id. button1); btn1.setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {// The operation popupwindow implemented by the OK button. dismiss () ;}}); button btn2 = (button) mview. findviewbyid (R. id. button2); btn2.setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {// cancel the operation popupwindow implemented by the button. dismiss () ;}}); popupwindow. setbackgrounddrawable (New bitmapdrawable (); popupwindow. showatlocation (findviewbyid (R. id. relativelayout1), gravity. center | gravity. center, 0, 0); // popupwindow is displayed in the center of the screen. update ();}
Content of soft_calendar_popup.xml:
<? XML version = "1.0" encoding = "UTF-8"?> <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "460px" Android: layout_height = "423px" Android: Background = "@ drawable/soft_calendar_popup_bg" Android: orientation = "vertical"> <textview Android: Id = "@ + ID/textview1" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: layout_margintop = "30px" Android: gravity = "center" Android: text = "prompt" Android: textcolor = "@ Android: color/White" Android: textsize = "25dip"/> <radiogroup Android: Id = "@ + ID/radiogroup1" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: layout_marginleft = "100px" Android: layout_marginright = "100px" Android: layout_margintop = "30px"> <radiobutton Android: Id = "@ + ID/radio0" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: checked = "true" Android: text = "Clear cache for the current day" Android: textsize = "20dip" Android: textcolor = "@ Android: color/White"/> <radiobutton Android: Id = "@ + ID/radio1" Android: textsize = "20dip" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: text = "Clear cache for the current month" Android: textcolor = "@ Android: color/White"/> <radiobutton Android: id = "@ + ID/Radio2" Android: textsize = "20dip" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: TEXT = "Clear all cache" Android: textcolor = "@ Android: color/White"/> </radiogroup> <linearlayout Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: layout_margintop = "15dip" Android: gravity = "center_horizontal"> <button Android: Id = "@ + ID/button1" Android: layout_width = "158px" Android: layout_height = "wrap_content" Android: layout_marginright = "30dip" Android: Background = "@ drawable/btn2" Android: gravity = "center" Android: TEXT = "OK" Android: textcolor = "@ Android: color/White"/> <button Android: Id = "@ + ID/button2" Android: layout_width = "158px" Android: layout_height = "wrap_content" Android: Background = "@ drawable/btn1" Android: gravity = "center" Android: text = "return" Android: textcolor = "#0072d7"/> </linearlayout>

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.