How to make custom dialog with rounded corners in android

前端 未结 16 925
半阙折子戏
半阙折子戏 2020-11-28 02:15

What I am trying to do: I am trying to make a custom dialog in android With rounded corners.

What is happening: I am able to make c

16条回答
  •  醉酒成梦
    2020-11-28 02:19

    In Kotlin, I am using a class DoubleButtonDialog.Java with line window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) as important one

    class DoubleButtonDialog(context: Context) : Dialog(context, R.style.DialogTheme) {
    
        private var cancelableDialog: Boolean = true
        private var titleDialog: String? = null
        private var messageDialog: String? = null
        private var leftButtonDialog: String = "Yes"
        //    private var rightButtonDialog: String? = null
        private var onClickListenerDialog: OnClickListener? = null
    
        override fun onCreate(savedInstanceState: Bundle?) {
            window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
            //requestWindowFeature(android.view.Window.FEATURE_NO_TITLE)
            setCancelable(cancelableDialog)
            setContentView(R.layout.dialog_double_button)
    //        val btnNegative = findViewById

    In layout, we can create a dialog_double_button.xml

        
        
    
            
    
            
    
            
    
            
    
            

    then use drawable.xml as

    
    
        
        
        
    
    

提交回复
热议问题