Android(Interpolator无法处理自定义对话框)

【Android(Interpolator无法处理自定义对话框)】青春须早为,岂能长少年。这篇文章主要讲述Android:Interpolator无法处理自定义对话框相关的知识,希望能为你提供帮助。
我从顶部创建了一个带有输入动画的对话框。像那样:

@Override protected void onCreate(Bundle savedInstanceState) { ... Window dialogWindow = getWindow(); assert dialogWindow != null; WindowManager.LayoutParams lp = dialogWindow.getAttributes(); DisplayMetrics dm = mContext.getResources().getDisplayMetrics(); lp.width = dm.widthPixels; lp.height = DisplayUtil.dip2px(mContext, 300); dialogWindow.setAttributes(lp); dialogWindow.setGravity(Gravity.TOP); dialogWindow.setWindowAnimations(R.style.DropDown); ... }< style name="DropDown" mce_bogus="1" parent="android:Animation"> < item name="android:windowNoTitle"> true< /item> < item name="android:windowIsFloating"> true< /item> < item name="android:windowEnterAnimation"> @anim/dropdown_in< /item> < item name="android:windowExitAnimation"> @anim/dropdown_out< /item> < /style>

动画没问题,但插补器不起作用。这是我定义的“dropdown_in”动画
< ?xml version="1.0" encoding="utf-8"?> < set xmlns:android="http://schemas.android.com/apk/res/android"> < translate android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:duration="1000" android:fromYDelta="-100%p" android:toYDelta="0" /> < /set>

答案看来你正在将一个Activity变成一个Dialog。在这种情况下,与Activity的动画存在冲突。您可能希望覆盖Activity的动画。请使用overridePendingTransition(R.style.DropDown,R.style.DropDown)更新您的代码;
@Override protected void onCreate(Bundle savedInstanceState) { ...overridePendingTransition(R.style.DropDown, R.style.DropDown); Window dialogWindow = getWindow(); assert dialogWindow != null; WindowManager.LayoutParams lp = dialogWindow.getAttributes(); DisplayMetrics dm = mContext.getResources().getDisplayMetrics(); lp.width = dm.widthPixels; lp.height = DisplayUtil.dip2px(mContext, 300); dialogWindow.setAttributes(lp); dialogWindow.setGravity(Gravity.TOP); dialogWindow.setWindowAnimations(R.style.DropDown); ... }


    推荐阅读