임은 여전히 노력 .getWidth()
및 .getHeight()
내가 그것을 단지 대화를위한이 아닌 활동에서 작동 생각과 내 대화 상자의 크기를 얻을 수 있습니다.
AlertDialog.Builder a = new AlertDialog.Builder(this);
View v = a.create().getCurrentFocus();
v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
int height = v.getMeasuredHeight();
int width = v.getMeasuredWidth();
또는이 방법 대화 상자가 화면에 표시 될 때 당신은 당신이 setOnShowListener를 통해에서 onShow 이벤트를 수신 시도 할 수 결정해야하는 경우
private int getDialogWidth(Dialog dialog)
{
DisplayMetrics dm = new DisplayMetrics();
dialog.getWindow().getWindowManager().getDefaultDisplay().getMetrics(dm);
String width = "" + dm.widthPixels ;
return (Integer.parseInt(width));
}
어떤 대화가 조각 대화 상자 또는 간단한 대화 상자입니까? – Triode
간단합니다 [Dialog] (http://developer.android.com/intl/ru/reference/android/app/Dialog.html) – boroloro
onAttachedToWindow() 또는 onLayoutParamsChanged가 도움이 될 수 있지만 대화 상자를 확장해야합니다. – Triode