我做了一个自定义动画主题(滑动向上和向下滑动)。 动画工作正常,上了年纪的Android版本.. 然而,当我尝试它在Android 4.0(ICS)上的关闭动画不起作用。只有向上滑动动画正常工作的ICS。
I made a theme with a custom animation (slide up and slide down). The animation works fine on the older android versions.. However, when I try it out on Android 4.0 (ICS) the on close animation doesn't work. Only the slide up animation works fine on ICS.
下面是我的主题我使用的动画:
Here is my theme I use for the animation:
<style name="myTheme" parent="android:Theme.Black">
<item name="android:windowTitleSize">45dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
<item name="android:windowAnimationStyle">@style/myTheme.Window</item>
</style>
<style name="myTheme.Window" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/push_up_in_no_alpha</item>
<item name="android:activityOpenExitAnimation">@anim/no_anim</item>
<item name="android:activityCloseEnterAnimation">@anim/no_anim</item>
<item name="android:activityCloseExitAnimation">@anim/push_down_out_no_alpha</item>
</style>
这里是 push_down_out_no_alpha.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="100%p"
android:duration="@android:integer/config_longAnimTime"/>
</set>
当我设置$ C $一个动画C中,它也能正常工作的ICS,但为什么不作为一个主题?
When i set a animation in code it also works fine on ICS, but why not as a theme?
this.overridePendingTransition(R.anim.no_anim,R.anim.push_down_out_no_alpha);
有谁知道为什么它不工作在Android 4.0(ICS)?
Does anyone know why it isn't working on Android 4.0 (ICS)?
从清单中指定的动画似乎在ICS :-(破 覆盖动画解决方案正常工作,但你可能不希望硬$ C C动画$。这将是很好的表现让他们,你会为其他平台版本的..所以......
Specifying animations from the manifest appears to be broken in ICS :-( The override animation solution works fine, but you probably don't want to hard-code the animations. It would be nice to get them from the manifest as you would for other versions of the platform.. so....
添加几个成员字段到你的活动举行动画的ID连接到你的活动。
add a couple of member fields to your activity to hold the ids of the animations attached to your activity..
protected int activityCloseEnterAnimation;
protected int activityCloseExitAnimation;
和地方在您的onCreate ...
and somewhere in your onCreate...
// Retrieve the animations set in the theme applied to this activity in the
// manifest..
TypedArray activityStyle = getTheme().obtainStyledAttributes(new int[] {android.R.attr.windowAnimationStyle});
int windowAnimationStyleResId = activityStyle.getResourceId(0, 0);
activityStyle.recycle();
// Now retrieve the resource ids of the actual animations used in the animation style pointed to by
// the window animation resource id.
activityStyle = getTheme().obtainStyledAttributes(windowAnimationStyleResId, new int[] {android.R.attr.activityCloseEnterAnimation, android.R.attr.activityCloseExitAnimation});
activityCloseEnterAnimation = activityStyle.getResourceId(0, 0);
activityCloseExitAnimation = activityStyle.getResourceId(1, 0);
activityStyle.recycle();
那么无论你的活动结束/应适用的动画包括...
then wherever your activity finishes/should apply animation include...
overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
和你的活动应该正确地履行你的主题/样式连接到活动中的表现进行设置。动画
and your activities should correctly honour the animations you set in the theme/style attached to activities in your manifest.