Custom dialog two or three things

Source: Internet
Author: User

:

Code:
 Public  class viewactivity extends Activity implements View. Onclicklistener {Dialog Mdialog;@Override    protected void onCreate(Bundle savedinstancestate) {requestwindowfeature (window.feature_no_title);Super. OnCreate (Savedinstancestate);        Setcontentview (R.layout.activity_view); InitDialog ( This); }@Override     Public void OnClick(View v)    {mdialog.show (); } Public void InitDialog(Context context) {View view = Layoutinflater.from (context). Inflate (R.layout.view_share,NULL); Mdialog =NewDialog (context, r.style.translucent_dialog);        Mdialog.setcontentview (view);        ImageView Iv_cancel = (ImageView) View.findviewbyid (r.id.iv_cancel); Iv_cancel.setonclicklistener (NewView.onclicklistener () {@Override             Public void OnClick(View v)            {Mdialog.dismiss ();    }        }); }}
the style of the transparent background:
<stylename="Translucent_dialog"Parent="@android: Style/theme.dialog"> <!--Set the background transparency of the custom layout --<Item name="Android:background"> @android: color/transparent</Item> <!--Set window background transparent, that is, go to border--<Item name="Android:windowbackground"> @android: color/transparent</Item> <!--Set whether the activity background is dimmed--<Item name="Android:backgrounddimenabled">false</Item> </style>
change backgrounddimenabled To remove gray background, effect

Tip:
//想要有这种透明效果的对话框时,不用使用AlertDialog.Builder创建dialog,否则效果会异常

Custom dialog two or three things

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.