Bud*_*ius 3 android android-animation android-actionbar transitiondrawable
我正在尝试使用TransitionDrawable在操作栏上执行一些颜色动画.
我正在尝试的代码非常简单,在onCreate期间,我将过渡drawable作为actionbar背景:
Drawable d = getResources().getDrawable(R.drawable.actionbar);
actionbarDrawable = new TransitionDrawable(new Drawable[] { d, d });
getActionBar().setBackgroundDrawable(actionbarDrawable);
Run Code Online (Sandbox Code Playgroud)
然后在事件上我替换了TransitionDrawable的第二个drawable并要求为它设置动画.
actionbarDrawable.setDrawableByLayerId(1, d);
actionbarDrawable.startTransition(666);
Run Code Online (Sandbox Code Playgroud)
我在我的活动上的RelativeLayout上尝试了相同的代码,它似乎工作正常,为什么ActionBar不想合作的任何想法以及如何使其工作?
谢谢.
小智 5
试试吧:
在values/string中:
<color name="blue">#FF4682B4</color>
<color name="red">#FFC30F0F</color>
Run Code Online (Sandbox Code Playgroud)
在你的班上:
ColorDrawable blue = new ColorDrawable(getResources().getColor(R.color.blue));
ColorDrawable red = new ColorDrawable(getResources().getColor(R.color.red));
ColorDrawable[] color = {blue, red};
TransitionDrawable trans = new TransitionDrawable(color);
actionBar.setBackgroundDrawable(trans);
trans.startTransition(500);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1400 次 |
| 最近记录: |