开发者

Creating styles in android without xml?

My question is.. Is it possible to create styles in android programmatically without any xml?

I wanted this because I need to use animation for a popup window when it enters and exits.. What i currently have is:

<resources>
    <style name="MyAnimation" parent="android:Animation">
    <item name="android:windowEnterAnimation">@anim/in_animation</item>
    <item name="android:windowExitAnimation">@anim/out_animation</item>
</style>

Howe开发者_如何学Cver, I want to decide the animation to use at runtime. This is because I would be calling the window which needs to be animated, on clicking some images on the screen. These images are placed in horizontal scrollview and there are 4-5 such horizontal scrollviews on the screen. And the animation I'm looking at is like..appearing from the view clicked, and growing to actual size alongwith translation to the center of the screen. Since the position of images is not fixed, I cannot use an xml directly to specify the animation and hence need to make the style via code..

If there is any other way to achieve what i am aiming at, then please do let me know.

Thanks.


You can use Activity.overridePendingTransition() method to get such behavior. This method accepts two animation resources: one for incoming activity and one for outgoing activity.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜