2017-01-18 62 views

回答

0

嘗試...

final Dialog dialog = new Dialog(context); 
      // Include dialog.xml file 
      dialog.setContentView(R.layout.your_custom_layout); 
      // Set dialog title 
      //dialog.setTitle("Custom Dialog"); 


      // set values for custom dialog components - text, image and button 
      final EditText name = (EditText) dialog.findViewById(R.id.name_edit); 


      dialog.show(); 

     /
      Button editButton = (Button) dialog.findViewById(R.id.editbtn); 
      // if decline button is clicked, close the custom dialog 
      editButton.setOnClickListener(new View.OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        // Close dialog 

        dialog.dismiss(); 

       } 
      }); 

      final Button cancenbtn = (Button) dialog.findViewById(R.id.cancelbtn); 
      // if decline button is clicked, close the custom dialog 
      cancelnbtn.setOnClickListener(new View.OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        // Close dialog 


        dialog.dismiss(); 
       } 
      }); 
4

這樣

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
              context, R.style.CustomAlertDialog); 
AlertDialog alertDialog = alertDialogBuilder.create(); 

在創建對話框中進行透明背景的活動您styles.xml

<style name="CustomAlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert"> 
    <item name="android:windowBackground">@drawable/popup_background</item> 
</style> 

popup_background.xml寫任何你想要的圓角半徑

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#FFFFFF" /> 
    <corners android:radius="6dp" /> 
</shape> 

這麼多的圓角半徑好運