Android AlertDialog with rounded corners

前端 未结 6 1610
猫巷女王i
猫巷女王i 2020-12-02 08:39

I have been trying to make my Alert Dialog with rounded corners but somehow I am not able to. I have tried and I failed. I tried to follow this blog http://blog.stylingandro

6条回答
  •  -上瘾入骨i
    2020-12-02 09:33

    I have try the same problem with below one and it works for me. Even for ICS also.

    1. First i have put the theme to my AlertDialog.

    final Dialog  nag = new Dialog(this,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
            nag.requestWindowFeature(Window.FEATURE_NO_TITLE);
            nag.setCancelable(true);
            nag.setContentView(R.layout.pop_exit);  
            Button btnNO = (Button)nag.findViewById(R.id.btn_popup_NO);
            Button btnYES = (Button)nag.findViewById(R.id.btn_popup_YES);
    
    
            btnNO.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
    
                nag.cancel();
    
    
                }
            });
    
            btnYES.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
    
                    System.exit(0);
    
                }
            });
    
            nag.show();
    

    2. Then have implemented the Custom Layout for the Dialog view

    pop_exit.xml

        
    
    
        
    
        
    
    
    
            
    
    
            
    
                

    3. Now add shape to the Background of parent layout of pop_exit.xml

    round.xml // shape file

        
    
        
        
        
    
    

    I just do it. It will works for you also for ICS.

    Hope it will help you. If not then let me know.

    Enjoy Coding...

    :)

提交回复
热议问题