2016-04-02 10 views
1

Wie das Dialogfeld auf beiden linken, rechten und unteren Ecken des Bildschirms in Android passen.Wie mache ich mein Dialogfeld als fill_parent in der Breite

googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { 
       @Override 
       public boolean onMarkerClick(Marker arg0) { 

        googleMap.getUiSettings().setMapToolbarEnabled(true); 

        final Dialog dialog = new Dialog(getActivity()); 
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
        dialog.setContentView(R.layout.mapdialogbox); 
        // dialog.setCanceledOnTouchOutside(false); 

        Window window = dialog.getWindow(); 
        WindowManager.LayoutParams wlp = window.getAttributes(); 
        wlp.gravity = Gravity.BOTTOM ; 
        wlp.width = LinearLayout.LayoutParams.FILL_PARENT; 
        wlp.x = -100; 
        dialog.show(); 
    } 
      }); 

This is how am getting by this code

Aber ich mein Dialogfeld zu den Ecken angebracht will, wie ich erreichen kann es

+0

http://stackoverflow.com/questions/2306503/how-to-make-an-alert-dialog-fill-90-of-screen-size – Manifest

+0

Fill Elternteil ist veraltet .... Sie sollten Match-Eltern verwenden – Rohan

+0

http://stackoverflow.com/questions/1362723/how-can-i-get-a-dialog-style-activity-window-to-fill-the-screen –

Antwort

0
Try this , may be its helpful for U. 

wlp.width = WindowManager.LayoutParams.MATCH_PARENT; 
wlp.height = WindowManager.LayoutParams.WRAP_CONTENT; 
0
I did my code : you have to create custom style and set it to your dialog. 
here is the my code : 

final Dialog dialog = new Dialog(context, R.style.CustomDialog);                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);                 dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT,enter code here ViewGroup.LayoutParams.FILL_PARENT);                LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);                View view = inflater.inflate(R.layout.full_screen_dialog, null);                                 cancel.setOnClickListener(new View.OnClickListener()                  @Override                 public void onClick(View v) {                  dialog.dismiss();                                 });                dialog.setContentView(view);                dialog.setCancelable(false);                dialog.show(); 

and here is the R.style.CustomDialog: 

<style name="CustomDialog" parent="@android:style/Theme.Dialog"> 
     <item name="android:windowIsTranslucent">true</item> 
     <item name="android:windowBackground">@android:color/black</item> 
     <item name="android:padding">80dp</item> 
     <item name="android:windowContentOverlay">@null</item> 
     <item name="android:windowNoTitle">true</item> 
     <item name="android:backgroundDimEnabled">false</item> 
     <item name="android:windowIsFloating">false</item> 
    </style> 

Happy code: i hope it will help you.`enter code here` 
+0

krank versuchen es Hemant –

0

eine übergeordnete Ansicht auf SetView() Methode von DialogBuilder gesetzt. fügen Sie dann ein Kind mit der Breite des Gerätebildschirms hinzu.

View view = createPopView(); 

AlertDialog.Builder builder = new AlertDialog.Builder(context); 
builder.setCancelable(true).setView(view); 


private View createPopView() { 

    LinearLayout layout = new LinearLayout(context); 
    layout.setOrientation(LinearLayout.VERTICAL); 

    EditText editText = new EditText(context); 
    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(screen_width,-2); 

    layout.addView(editText); 
    return layout; 
} 
0

Entfernen Sie alle Auffüllung, die Sie auf Ihrem Layout haben.

0

testen Werde

@Override 
public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 

setContentView(R.layout.your_layout); 

getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); 
} 
Verwandte Themen