本文整理匯總了Java中android.app.Dialog.onWindowAttributesChanged方法的典型用法代碼示例。如果您正苦於以下問題:Java Dialog.onWindowAttributesChanged方法的具體用法?Java Dialog.onWindowAttributesChanged怎麽用?Java Dialog.onWindowAttributesChanged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.Dialog
的用法示例。
在下文中一共展示了Dialog.onWindowAttributesChanged方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: adjustWH
import android.app.Dialog; //導入方法依賴的package包/類
public static void adjustWH( Dialog dialog, ConfigBean bean ) {
if (dialog == null){
return;
}
Window window = dialog.getWindow();
View rootView = window.getDecorView();
//window.setWindowAnimations(R.style.dialog_center);
WindowManager.LayoutParams wl = window.getAttributes();
int width = window.getWindowManager().getDefaultDisplay().getWidth();
int height = window.getWindowManager().getDefaultDisplay().getHeight();
int measuredHeight = rootView.getMeasuredHeight();
float ratio = 0.85f;
if(bean.type ==DefaultConfig.TYPE_IOS_BOTTOM){
ratio = 0.95f;
}else if(bean.type ==DefaultConfig.TYPE_IOS_CENTER_LIST){
ratio = 0.9f;
}
if(width > height){//寬屏
ratio = 0.5f;
}
if(istheTypeOfNotAdjust(bean.type)){
/*wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;*/
}else {
// rootView.setPadding(0,30,0,30);
wl.width = (int) (width * ratio);
if (measuredHeight > height* 0.9){
wl.height = (int) (height* 0.9);
}
}
dialog.onWindowAttributesChanged(wl);
}
示例2: setDialogStyle
import android.app.Dialog; //導入方法依賴的package包/類
public static void setDialogStyle(Context context, Dialog dialog, int measuredHeight, BuildBean bean) {
if (dialog == null) {
return;
}
Window window = dialog.getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.setGravity(bean.gravity);
WindowManager.LayoutParams wl = window.getAttributes();
// 以下這兩句是為了保證按鈕可以水平滿屏
int width = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
int height = (int) (((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() * 0.9);
if (bean.type != DialogConfig.TYPE_MD_LOADING) {
wl.width = (int) (width * 0.94); // todo keycode to keep gap
} else {
wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
wl.height = ViewGroup.LayoutParams.WRAP_CONTENT; //TODO 一般情況下為wrapcontent,最大值為height*0.9
if (measuredHeight > height) {
wl.height = height;
}
if (context instanceof Activity) {
Activity activity1 = (Activity) context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (activity1.isDestroyed()) {
context = DialogUIUtils.appContext;
}
}
} else {
wl.type = WindowManager.LayoutParams.TYPE_TOAST;
//todo keycode to improve window level,同時要讓它的後麵半透明背景也攔截事件,不要傳遞到下麵去
//todo 單例化,不然連續彈出兩次,隻能關掉第二次的
}
dialog.onWindowAttributesChanged(wl);
}
示例3: setDialogStyle
import android.app.Dialog; //導入方法依賴的package包/類
public static void setDialogStyle(Context context, Dialog dialog, int measuredHeight, BuildBean bean) {
if (dialog == null) {
return;
}
Window window = dialog.getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.setGravity(bean.gravity);
WindowManager.LayoutParams wl = window.getAttributes();
// 以下這兩句是為了保證按鈕可以水平滿屏
int width = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
int height = (int) (((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() * 0.9);
if (bean.type != CommonConfig.TYPE_MD_LOADING_VERTICAL) {
wl.width = (int) (width * 0.94); // todo keycode to keep gap
} else {
wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
wl.height = ViewGroup.LayoutParams.WRAP_CONTENT; //TODO 一般情況下為wrapcontent,最大值為height*0.9
if (measuredHeight > height) {
wl.height = height;
}
if (context instanceof Activity) {
Activity activity1 = (Activity) context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (activity1.isDestroyed()) {
context = DialogUIUtils.appContext;
}
}
} else {
wl.type = WindowManager.LayoutParams.TYPE_TOAST;
//todo keycode to improve window level,同時要讓它的後麵半透明背景也攔截事件,不要傳遞到下麵去
//todo 單例化,不然連續彈出兩次,隻能關掉第二次的
}
dialog.onWindowAttributesChanged(wl);
}