So wählen Sie die position von einem AlertDialog aus dem Bildschirm oben in Android?

Den ich einstellen will AlertDialog position hinter der Statusleiste, wenn die Inhalte in mein-Dialog zu erhöhen, Wie das zu tun? Ich bin erstellen einer benutzerdefinierten AlertDialog mit meinem eigenen layout.... Bitte helfen Sie mir....


Unten ist mein code, ich bin Einstellung der Höhe und x-y-position der alertDialog, aber es doesnot zeigen Ihre Wirkung..

AlertDialog.Builder builder = new AlertDialog.Builder(this);
       LayoutInflater inf = getLayoutInflater();
        View layout = inf.inflate(R.layout.main, null);
        builder.setView(layout);
        builder.setTitle("Add to Home screen");
    AlertDialog dialog = builder.create();
        WindowManager.LayoutParams WMLP = dialog.getWindow().getAttributes();
        int dialogOriginalHeight = WMLP.height;
    WMLP.height += 750;
    Log.i("XnY", "x="+WMLP.x+", y="+WMLP.y);
    WMLP.x = -10;   //x position
    WMLP.y = -10;   //y position
    Log.i("XnY", "x="+WMLP.x+", y="+WMLP.y);
    dialog.getWindow().setAttributes(WMLP);
    Log.i("POSITION", "POS::HEIGHT:"+WMLP.height);
    dialog.show();
  • ich denke, dass du das getan hast mit .setView() .. konnte Sie zeigen, dass Ihre codes eigentlich ?
  • Unten ist mein code, ich bin Einstellung der Höhe und x-y-position der alertDialog, aber es doesnot zeigen Ihre Wirkung....
  • AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inf = getLayoutInflater(); View layout = inf.inflate(R. layout.Haupt -, null); builder.setView(layout); AlertDialog dialog - = - generator.create(); WindowManager.LayoutParams WMLP = - dialog.getWindow().getAttributes(); WMLP.Höhe += 750; Log.ich("XnY", "x="+WMLP.x+", y="+WMLP.y); WMLP.x = -10; //x-position WMLP.y = -10; //y-position Melden.ich("XnY", "x="+WMLP.x+", y="+WMLP.y); dialog.getWindow().setAttributes(WMLP); Log.ich("POSITION", "POS::HÖHE:"+WMLP.Höhe); dialog.show();
InformationsquelleAutor KISH | 2010-07-01
Schreibe einen Kommentar