Unable to get proper custom AlertDialog

后端 未结 2 493
广开言路
广开言路 2021-01-26 14:55

I have been trying to set a custom AlertDialog but was not able to get correctly.

prompt.xml




        
相关标签:
2条回答
  • 2021-01-26 15:32

    Try this

    Dialog dialog = new Dialog(MainAppActivity.this, R.style.PauseDialog);
    dialog.setContentView(R.layout.prompt);
    dialog.setCancelable(true);
    dialog.show();
    

    and in style.xml

    <style name="PauseDialog" parent="@android:style/Theme.Translucent.NoTitleBar"></style>
    
    0 讨论(0)
  • 2021-01-26 15:51
        Dialog d=new Dialog(this);
        //Add this
        d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    
        d.setContentView(R.layout.prompt);
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        d.getWindow().setAttributes(lp);
        d.show();
    
    0 讨论(0)
提交回复
热议问题