我正在开发一个自定义步进器。一切正常。
我现在要做的是在填充当前步骤时为步进器设置动画。
这张图片显示了我的想法:
这是我在设置线条、标题和图标 src 的颜色时的代码:
private void DrawStepper(int position) {
switch (position) {
case 0:
imgStepShipper.setImageResource(R.drawable.ic_current_step);
txtStepShipper.setTextColor(getResources().getColor(R.color.colorPrimary));
line.setBackgroundColor(getResources().getColor(R.color.colorDarkWhite));
imgStepConsignee.setImageResource(R.drawable.ic_unselected_step);
txtStepConsignee.setTextColor(getResources().getColor(R.color.colorDarkSuperWhite));
line2.setBackgroundColor(getResources().getColor(R.color.colorDarkWhite));
imgStepShipment.setImageResource(R.drawable.ic_unselected_step);
txtStepShipment.setTextColor(getResources().getColor(R.color.colorDarkSuperWhite));
line3.setBackgroundColor(getResources().getColor(R.color.colorDarkWhite));
imgStepCharges.setImageResource(R.drawable.ic_unselected_step);
txtStepCharges.setTextColor(getResources().getColor(R.color.colorDarkSuperWhite));
break;
case 1:
imgStepShipper.setImageResource(R.drawable.ic_done_step);
txtStepShipper.setTextColor(getResources().getColor(R.color.colorPrimary));
line.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
imgStepConsignee.setImageResource(R.drawable.ic_current_step);
txtStepConsignee.setTextColor(getResources().getColor(R.color.colorPrimary));
line2.setBackgroundColor(getResources().getColor(R.color.colorDarkWhite));
imgStepShipment.setImageResource(R.drawable.ic_unselected_step);
txtStepShipment.setTextColor(getResources().getColor(R.color.colorDarkSuperWhite));
line3.setBackgroundColor(getResources().getColor(R.color.colorDarkWhite));
imgStepCharges.setImageResource(R.drawable.ic_unselected_step);
txtStepCharges.setTextColor(getResources().getColor(R.color.colorDarkSuperWhite));
break;
case 2:
imgStepShipper.setImageResource(R.drawable.ic_done_step);
txtStepShipper.setTextColor(getResources().getColor(R.color.colorPrimary));
line.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
imgStepConsignee.setImageResource(R.drawable.ic_done_step);
txtStepConsignee.setTextColor(getResources().getColor(R.color.colorPrimary));
line2.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
imgStepShipment.setImageResource(R.drawable.ic_current_step);
txtStepShipment.setTextColor(getResources().getColor(R.color.colorPrimary));
line3.setBackgroundColor(getResources().getColor(R.color.colorDarkWhite));
imgStepCharges.setImageResource(R.drawable.ic_unselected_step);
txtStepCharges.setTextColor(getResources().getColor(R.color.colorDarkSuperWhite));
break;
case 3:
imgStepShipper.setImageResource(R.drawable.ic_done_step);
txtStepShipper.setTextColor(getResources().getColor(R.color.colorPrimary));
line.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
imgStepConsignee.setImageResource(R.drawable.ic_done_step);
txtStepConsignee.setTextColor(getResources().getColor(R.color.colorPrimary));
line2.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
imgStepShipment.setImageResource(R.drawable.ic_done_step);
txtStepShipment.setTextColor(getResources().getColor(R.color.colorPrimary));
line3.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
imgStepCharges.setImageResource(R.drawable.ic_current_step);
txtStepCharges.setTextColor(getResources().getColor(R.color.colorPrimary));
break;
}
}
位置是当前步骤。
这是我的用户界面:
正如我所说,我想在每次从一个步骤移动到另一个步骤时为线条设置动画。
谢谢 :)