Create shadow for dialog

前端 未结 2 1156
攒了一身酷
攒了一身酷 2021-01-03 05:23

I want to create a shadow for my custom dialog is that possible ?

GhazalActivity.public void viewShareMenu() {
        Dialog share=new Dialog(this,R.style.s         


        
2条回答
  •  余生分开走
    2021-01-03 06:04

    I have created my own custom dialog with a dropped shadow, you can use it as your desire, in the first step you should create a Android shape for both shadow and dialog frame. Here is what I have supplied (dialog_frame_shadow.xml):

    
    
        
             
                
                
                
            
        
        
             
                
                
                
            
        
    
    

    In the next step you should change your dialog theme as what is in the following:

     
    

    Now you are done, just create a new instance of the Dialog class and apply this theme to it (in Dialog constructor):

    Dialog dialog = new Dialog(this, R.style.my_dialog_theme);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.mdialog);
    dialog.show();
    

    Here is its screenshot:
    enter image description here

提交回复
热议问题