是否可以为系统警报类型 View 设置动画?如果是这样呢?
我试过了,但没用:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View view = new View(this);
view.setBackgroundColor(0x33FF0000);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.blink);
view.startAnimation(animation);
WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(-1, -1, 2006, 1336, -3);
windowManager.addView(view, layoutParams);
}
blink.xml:
<alpha
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromAlpha="0.0"
android:toAlpha="1"
android:duration="500"
android:repeatMode="reverse"
android:repeatCount="9999999"/>
此代码将 View 添加到系统中,但它不是动画的。
我找到了解决方案:
要动画的view不能直接添加到top window,因为android的top window不是真正的ViewGroup。因此必须先将 View 添加到像 FrameLayout 这样的 ViewGroup 中,然后再将此 ViewGroup 添加到顶部窗口中。
关于android - 动画系统警报类型 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17537672/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://www.ogeek.cn/) | Powered by Discuz! X3.4 |