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>