开发者

How do you create a Google Maps-esque drop down dialog?

In the Google Maps application, when you open the menu and click on "Directions", it pops up a dialog that is unique to Google Maps. It keeps the MapView in the background, but displays the search dialog from the top (or bottom, if you're on an old version of Android).

I was curious if anyone knew how they achieved this e开发者_Go百科ffect. I'm willing to create a custom Dialog, but it seems that Dialogs are designed to pop into the middle of the screen (any other types of dialogs are denied permission as system dialogs). What trick is Google Maps using?


Just make your activity's root layout a FrameLayout or RelativeLayout (so your new view can overlap what's on screen). Then just add a layout with whatever you want as a child of that root layout (say, by inflating your desired dialog's XML into it when a button is clicked somewhere, either manually or using a ViewStub), and define a LayoutAnimation on the child before showing it.

For more on LayoutAnimations check out the API Demos app that ships with the Android SDK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜