I want to add load animation to custom dialog, I was able to do it in java but I m having issue to do the same in kotlin it gives me the below error
E/AndroidRuntime: FATAL EXCEPTION: main
android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:229)
at com.android.internal.app.AlertController.installContent(AlertController.java:234)
at android.app.AlertDialog.onCreate(AlertDialog.java:337)
at android.app.Dialog.dispatchOnCreate(Dialog.java:355)
at android.app.Dialog.show(Dialog.java:260)
at com.autodroid.demo.MainActivity.show(MainActivity.kt:66)
at com.autodroid.demo.MainActivity$onCreate$1.onClick(MainActivity.kt:32)
at android.view.View.performClick(View.java:4204)
at android.view.View$PerformClick.run(View.java:17355)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
Below is my code to create a dialog in kotlin
val dialogBuilder = AlertDialog.Builder(activity)
val inflater = activity?.layoutInflater
val dialogView = inflater?.inflate(R.layout.newly_dialog, null)
dialogBuilder.setView(dialogView)
val tvPopText = dialogView?.findViewById<View>(R.id.tvPopText) as TextView
val dBuilder = dialogBuilder.create()
//-----> Issue :(
var viewGroup = dBuilder.window.decorView
viewGroup.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.slide_down))
//-----> Issue
dBuilder.show()
Any pointer will be appreciated , Thanks in advance :)