Hi Dianne, Is this the way also to provide in and out animations to dialogs?
Or Can you suggest how we can add in and out animations to dialogs/ activities to provide a transition effect ? On Jan 19, 11:12 pm, "Dianne Hackborn" <hack...@android.com> wrote: > Call it after the requestFeature() calls. > > But for an alert dialog, you probably want to animate the window itself not > the contents inside. You do this by setting a style resource on the > WindowManager.LayoutParams.windowAnimation. > > On Mon, Jan 19, 2009 at 9:06 AM, Tom Medhurst > <tom.medhu...@googlemail.com>wrote: > > > > > > > > > So any ideas how I can call: getDecorView() without getting the error: > > "AndroidRuntimeException: requestFeature() must be called before > > adding content" ...? > > > On Jan 12, 8:39 pm, Tom Medhurst <tom.medhu...@googlemail.com> wrote: > > > I have an AlertDialog box instance I created from AlertDialog.Builder > > > and I want to animate it with a anim/appear1.xml file I created > > > earlier. > > > > Normally I would initialize the animation using > > > AnimationUtils.loadAnimation, but I am having a problem applying this > > > animation to the AlertDialog. > > > > To get the View of the dialog I call alertDialogInstance.getWindow > > > ().getDecorView().setAnimation(...) > > > However this throws an exception: > > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): > > > android.util.AndroidRuntimeException: requestFeature() must be called > > > before adding content > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > com.android.internal.policy.impl.PhoneWindow.requestFeature > > > (PhoneWindow.java:199) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > com.android.internal.app.AlertController.installContent > > > (AlertController.java:166) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.AlertDialog.onCreate(AlertDialog.java:146) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.Dialog.dispatchOnCreate(Dialog.java:268) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.Dialog.show(Dialog.java:207) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > tommed.lastFMForAndroid.MusicPlayerActivity.startStreaming > > > (MusicPlayerActivity.java:393) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > tommed.lastFMForAndroid.MusicPlayerActivity.setSongInfo > > > (MusicPlayerActivity.java:317) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > tommed.lastFMForAndroid.MusicPlayerActivity.onCreate > > > (MusicPlayerActivity.java:239) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: > > > 1122) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java: > > > 2103) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: > > > 2156) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.ActivityThread.access$1800(ActivityThread.java:112) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.os.Handler.dispatchMessage(Handler.java:88) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.os.Looper.loop(Looper.java:123) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > android.app.ActivityThread.main(ActivityThread.java:3742) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > java.lang.reflect.Method.invokeNative(Native Method) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > java.lang.reflect.Method.invoke(Method.java:515) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run > > > (ZygoteInit.java:739) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497) > > > 01-12 20:30:46.976: ERROR/mediaPlayer(555): at > > > dalvik.system.NativeStart.main(Native Method) > > > > I had a read of the documentation and I tried the following which > > > didn't make any difference: > > > Window dialogWindow = mBufferDialog.getWindow(); > > > dialogWindow.requestFeature > > > (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); > > > dialogWindow.requestFeature > > > (WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR); > > > dialogWindow.getDecorView().setAnimation(AnimationUtils.loadAnimation > > > (this, R.anim.expand_in)); > > > > Anyone got any ideas what I am missing? > > > Thanks > > > Tom > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support. All such questions should be posted on public > forums, where I and others can see and answer them.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---