Alex Orlov..
118
有几种,取决于你的意思是什么样的闪烁.例如,您可以使用alpha动画并在首次出现按钮时启动它.当用户点击按钮时,就在你OnClickListener刚刚做的时候clearAnimation().
例:
public void onCreate(Bundle savedInstanceState) {
final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
animation.setDuration(500); // duration - half a second
animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely
animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in
final Button btn = (Button) findViewById(R.id.your_btn);
btn.startAnimation(animation);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View view) {
view.clearAnimation();
}
});
}
亚历克斯:谢谢快速的解决方案.我正在使用我的第一个应用程序学习Android并且没有动画 - 现在应该这样做. (2认同)