Customize a full screen AlertDialog ., Full Screen alertdialog

Source: Internet
Author: User

Customize a full screen AlertDialog ., Full Screen alertdialog

 

 

...........

Final MyDialog dialog = new MyDialog (this); LayoutInflater inflater = getLayoutInflater (); LinearLayout layout = (LinearLayout) inflater. inflate (R. layout. layout, null); CautionTv = (TextView) layout. findViewById (R. id. ion_ TV); ContentTv = (TextView) layout. findViewById (R. id. ntent_ TV); LanguageTv = (TextView) layout. findViewById (R. id. guage_ TV); OkBt = (Button) layout. findViewById (R. id. _ OK _bt); OkBt. se TOnClickListener (new OnClickListener () {@ Override public void onClick (View arg0) {if (dialog! = Null) {dialog. cancel () ;}}); dialog. show (); dialog. setCancelable (false); dialog. setContentView (layout); // The show method must be in front

 

 

 

 

 

Import android. app. activity; import android. app. alertDialog; import android. content. context; import android. OS. bundle; import android. view. gravity; import android. view. windowManager; import android. view. viewGroup. layoutParams; import com. android. launcher. r;/*** custom pop-up box * @ author xiebin **/public class MyDialog extends AlertDialog {Context mContext; public MyDialog (Context context) {super (context, R. style. myDialog); // custom full screen style this. mContext = context;} @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState) ;}@ Override public void show () {super. show ();/*** set the width to full screen. You must set the width to the back of show */WindowManager. layoutParams layoutParams = getWindow (). getAttributes (); layoutParams. gravity = Gravity. BOTTOM; layoutParams. width = LayoutParams. MATCH_PARENT; layoutParams. height = LayoutParams. MATCH_PARENT; getWindow (). getDecorView (). setPadding (0, 0, 0, 0); getWindow (). setAttributes (layoutParams );}}

 

 

/Launcher/res/values/styles. xml

<! -- Full screen style --> <style name = "MyDialog" parent = "@ android: style/Theme. NoTitleBar. Fullscreen"> <! -- Whether a Border exists --> <item name = "android: windowFrame"> @ null </item> <! -- Whether it is above the suspended Activity --> <item name = "android: Refreshing wisfloating"> true </item> <! -- Title --> <item name = "android: windowNoTitle"> true </item> <! -- Shadow --> <item name = "android: javaswistranslucent"> true </item> <! -- Translucent --> <! -- Disappears outside the vertex --> <item name = "android: windowCloseOnTouchOutside"> false </item> </style>

 

Related Article

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.