2015-02-03 2 views
4

내 응용 프로그램에서 dialogfragment을 표시하고있어 내가 화면 하단에 조각 'y 위치를 설정 한 경우에도 여전히 볼 여유가 있다고주의 사항 :안드로이드는 부동 DialogFragment 제거 마진

 Display display = getActivity().getWindowManager().getDefaultDisplay(); 
     Point size = new Point(); 
     display.getSize(size); 
     windowParams.y = size.y; 

아래 스크린 샷에서 옅은 파란색 (내 대화 상자)이 화면 하단으로 설정되어 있음에도 불구하고 화면 하단에서 여전히 약간 떨어져있는 것을 볼 수 있습니다. 이 마진은 어떻게 제거합니까?

setStyle(DialogFragment.STYLE_NO_FRAME, 0); 

답변

4

이 솔루션은이 라인을 추가하는 것입니다.

//Dialog fragment will be shown at the bottom of screen 

//if you want to show on entire screen just comment it 

getDialog().getWindow().setGravity(Gravity.BOTTOM); 

WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); 
Window window = getDialog().getWindow(); 



lp.copyFrom(window.getAttributes()); 

//This makes the dialog take up the full width 



lp.width = WindowManager.LayoutParams.MATCH_PARENT; 

//For full height set it to MATCH_PARENT else WRAP_CONTENT 



lp.height = WindowManager.LayoutParams.WRAP_CONTENT; 

window.setAttributes(lp); 
+2

대화 상자가 사라집니다. –

0

바닥, 상단에 추가 마진, 코드 라인 아래 왼쪽과 오른쪽 사용을 방지하려면 :

margins