Displaying activity with custom animation

后端 未结 3 1522
终归单人心
终归单人心 2020-12-07 12:09

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-ri

相关标签:
3条回答
  • 2020-12-07 12:48

    It doesn't matter that your starting from a widget, wrote a tutorial so that you can animate your activity's in and out. This animation is set within the activity that your bringing into focus so you can do it with pendingIntent as well.

    Enjoy:

    http://blog.blundellapps.co.uk/animate-an-activity/

    0 讨论(0)
  • 2020-12-07 12:49

    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.

    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/themes.xml

    Here's my a portion of my styles.xml and manifest.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

        <activity
            android:name="com.me.activity.MyActivity"
            android:label="@string/display_name"
            android:theme="@style/MyTheme">
        </activity>
    
    0 讨论(0)
  • 2020-12-07 13:02
    startActivity(intent);
    overridePendingTransition(R.anim.slide_top_to_bottom, R.anim.hold);
    

    Check this link: overridePendingTransition method

    Edit:

    To Achieve the Animation for the Views. You have use the startAnimation Method like below

    view.startAnimation(AnimationUtils.loadAnimation(
                     WidgetActivity.this,R.anim.slide_top_to_bottom));
    

    Check this link:

    0 讨论(0)
提交回复
热议问题