設置 DialogFragment 的背景顏色透明

Android 開發中,可否設置 DialogFragment 的背景顏色?

系統默認的過於深了,很是不友好。

解決方案:
1.在DialogFragment的onCreateView裏面設置,能夠將對話框內部的背景設爲透明
getDialog().getWindow().setBackgroundDrawable(newColorDrawable(Color.TRANSPARENT));

2.在DialogFragment的onstart裏面設置,能夠將對話框外部的背景設爲透明
@Override
	public void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		
		Window window = getDialog().getWindow();
		WindowManager.LayoutParams windowParams = window.getAttributes();
		windowParams.dimAmount = 0.0f;
		
		window.setAttributes(windowParams);
	}