DialogFragment是否将XML扩展到全屏?

时间:2019-02-28 18:46:12

标签: java android android-layout kotlin android-dialogfragment

我已经实现了Django==2.1.5,但是结果看起来像这样:

enter image description here

代替这个(从XML预览):

enter image description here

片段的onViewCreated

DialogFragment

SuccessDialog类

val button = view.findViewById(R.id.button_register) as Button
button.setOnClickListener{
    Log.d(TAG, "Clicked")
    val dialog = SuccessDialog()
    dialog.show(fragmentManager, "success dialog")
}

对话框的XML:

class SuccessDialog: DialogFragment() {
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view = inflater.inflate(R.layout.dialog_success, container, false)
        val button: Button = view.findViewById(R.id.button_ok)
        button.setOnClickListener{
            dialog.dismiss()
        }
        return view
    }
}

1 个答案:

答案 0 :(得分:1)

 tools:...

对于 xml预览 。因此,请使用:

 app:srcCompat="..." 

代替

 tools:srcCompat="..."

要更改尺寸,请在onCreateView的{​​{1}}中使用它

SuccessDialog