【发布时间】:2014-05-05 18:38:05
【问题描述】:
背景
可以更改操作栏的背景,甚至可以在两种颜色之间设置动画,例如:
public static void animateBetweenColors(final ActionBar actionBar, final int colorFrom, final int colorTo,
final int durationInMs) {
final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.addUpdateListener(new AnimatorUpdateListener() {
ColorDrawable colorDrawable = new ColorDrawable(colorFrom);
@Override
public void onAnimationUpdate(final ValueAnimator animator) {
colorDrawable.setColor((Integer) animator.getAnimatedValue());
actionBar.setBackgroundDrawable(colorDrawable);
}
});
if (durationInMs >= 0)
colorAnimation.setDuration(durationInMs);
colorAnimation.start();
}
问题
我找不到获取动作模式视图的方法,因此我可以在某些情况下更改其背景(当它显示时)。
我尝试了什么
我发现的唯一一件事是一种 hack-y 方式,它假设动作模式的 id 将保持不变,即使这仅适用于“完成”按钮的视图(看起来像“ V”,实际上更像是“取消”)。
我还找到了如何通过主题更改它,但这不是我需要的,因为我需要以编程方式进行。
问题
如何获得 actionMode 的视图,或者更准确地说,如何使用动画更改其背景?
【问题讨论】:
-
@ZohraKhan 正如我已经提到的,我知道如何更改操作栏的背景。我想知道如何改变它的ActionMode的背景。
标签: android background android-actionbar android-actionmode