android alert,Android AlertDialog的基本使用
AlertDialog:是一種警告,提醒對(duì)話框;
Builder的創(chuàng)建(是AlertDialog的輔助類,用于創(chuàng)建AlertDialog實(shí)例,以及屬性的設(shè)置)
AlertDialog.Builder builder =newAlertDialog.Builder(Context context);
設(shè)置自定義style屬性
AlertDialog.Builder builder =newAlertDialog.Builder(Context context,int id);
@null
true
false
true
@drawable/ic_launch
false
0.5
@anim/out
@anim/off
設(shè)置window的屬性----窗口的大小
Window window = dialog.getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
//設(shè)置寬度和高度
lp.width= WindowManager.LayoutParams.MATCH_PARENT;
lp.height= WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(lp);
設(shè)置window的屬性----窗口的位置
LayoutParams params =new LayoutParams();
params.x = -80;//設(shè)置x坐標(biāo)
params.y = -60;//設(shè)置y坐標(biāo)
//設(shè)置屏幕不變成灰色
params.flags= WindowManager.LayoutParams.*FLAG_BLUR_BEHIND*
params.gravity= Gravity.BOTTOM;
win.setAttributes(params);
window.setGravity(Gravity.*TOP*);
點(diǎn)擊Dialog以外范圍DIalog不消失:
dialog.setCanceledOnTouchOutside(false);
總結(jié):
總結(jié)
以上是生活随笔為你收集整理的android alert,Android AlertDialog的基本使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: android gridview ite
- 下一篇: 鸿蒙智慧电视,华为的鸿蒙电视与智能电视有