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