2016-11-23 2 views

Antwort

1

Versuchen, dies zu ändern

dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 

dieser

dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, 
       WindowManager.LayoutParams.MATCH_PARENT); 
+0

'ViewGroup.LayoutParams.MATCH_PARENT' und' WindowManager.LayoutParams.MATCH_PARENT' beide gleich konstanter Wert haben, so wird dies keine Auswirkungen –

2

unten Stil hinzufügen

<style name="Theme_Dialog" parent="android:Theme.Holo.Dialog"> 
     <item name="android:windowMinWidthMajor">100%</item> 
     <item name="android:windowMinWidthMinor">100%</item> 
</style> 

und

final Dialog dialog = new Dialog(getActivity(), R.style.Theme_Dialog); 
3

Versuchen Sie den folgenden Code, damit wird Ihr Problem gelöst.

//Grab the window of the dialog, and change the width 
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); 
    Window window = dialog.getWindow(); 
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 
    lp.copyFrom(window.getAttributes()); 
    //This makes the dialog take up the full width 
    lp.width = WindowManager.LayoutParams.MATCH_PARENT; 
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT; 
    window.setAttributes(lp); 
+1

dies wie Magie funktioniert, dank –

+0

Sie willkommen, zu Glade zu hören, dass sein hilft ... –