显示活动与自定义动画 [英] Displaying activity with custom animation

查看:94
本文介绍了显示活动与自定义动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启动活动被点击时一个小部件。我想有某种奇特的动画显示此活动,而不是Android的标准滚动从右。我有问题的设置,虽然。这是我有:

I have a widget which starts an activity when it is clicked. I'd like to have some kind of fancy animation to display this activity, rather than the standard scroll-from-right of Android. I'm having problems setting it, though. This is what I have:

slide_top_to_bottom.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
    <translate android:fromYDelta="-100%" android:toXDelta="0" android:duration="100" />
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="50" />
</set>

...这是中引用的 anim.xml

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
        android:delay="50%"
        android:animation="@anim/slide_top_to_bottom" />

但后来我在哪里的参考呢?我都试过基地我要滑入活动的元素,并在清单中activitiy的入口,均获得

But then where do I reference it from? I've tried both the base element of the activity I want to slide in, and the activitiy's entry in the manifest, both times with

android:layoutAnimation="@+anim/anim"

我可能会做这一切是错误的。任何帮助是非常AP preciated!

I might be doing this all wrong. Any help is much appreciated!

推荐答案

您可以创建自定义主题以参考自己的动画,并把它应用到你的活动在manifest文件。 我成功地应用自定义动画使用下面的样式定义的浮动窗口。你也许可以做同样的事情,如果你设置你的风格的母公司是@android:款式/ Animation.Activity

You can create a custom Theme with a reference to your own animation and apply it to your Activity in your manifest file. I was successful in applying a custom animation for a floating window using the following style definition. You might be able to do something similar if you set the parent of your style to be "@android:style/Animation.Activity"

看一下你可以覆盖哪些进一步的细节如下文件。

Look at the following files for further details on what you can override.

<一个href="https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml">https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml <一href="https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml">https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml

下面是我的styles.xml和manifest.xml的

Here's my a portion of my styles.xml and manifest.xml

styles.xml

styles.xml

<style name="MyTheme" parent="@android:style/Theme.Panel">
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:windowAnimationStyle">@style/MyAnimation.Window</item>
</style>

<!-- Animations --> 
<style name="MyAnimation" /> 

<!-- Animations for a non-full-screen window or activity. --> 
<style name="MyAnimation.Window" parent="@android:style/Animation.Dialog"> 
    <item name="android:windowEnterAnimation">@anim/grow_from_middle</item>
    <item name="android:windowExitAnimation">@anim/shrink_to_middle</item>
</style> 

的Manifest.xml

Manifest.xml

    <activity
        android:name="com.me.activity.MyActivity"
        android:label="@string/display_name"
        android:theme="@style/MyTheme">
    </activity>

这篇关于显示活动与自定义动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆