操作栏中的菜单项Sherlock在每次搜索时变暗

时间:2014-01-06 20:41:29

标签: android animation actionbarsherlock menuitem

我使用以下代码

为菜单添加了一个刷新按钮
refreshItem = menu.add(Menu.NONE, REFRESH_ITEM_ID, 1, getString(R.string.refresh));
refreshItem.setIcon(getResources().getDrawable(R.drawable.ic_action_refresh));
refreshItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

当应用启动时,这是刷新图标的颜色 App starting screen

如果刷新处于活动状态,即它已设置动画(使用以下代码)

void setupAnimation() {
    RotateAnimation.RELATIVE_TO_SELF, 0.36f, 
    RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(800);
    rotateAnimation.setRepeatCount(Animation.INFINITE);
    refreshItem.setActionView(R.layout.ic_action_bar_refresh_layout);       
    animatedIcon = (ImageView) refreshItem.getActionView();
    ...    
}

///
///
public void startRefreshingAnimation() {
    animatedIcon.startAnimation(rotateAnimation);
}

然后,每次点击搜索图标时,它会逐渐变暗。 enter image description here enter image description here

请注意,只有在动画图标时才会出现图标变暗的行为。

0 个答案:

没有答案
相关问题