自定义StepView,仿外卖配送进度

效果图
使用

可在layout文件下设置以下属性。

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="StepView">
        <attr name="step_size" format="dimension"/><!--step的size,也就是image的大小-->
        <attr name="line_size" format="dimension"/><!--线宽-->
        <attr name="text_size" format="dimension"/><!--文字大小-->
        <attr name="text_line_margin" format="dimension"/><!--文字和线之间的间距-->
        <attr name="normal_line_color" format="color"/><!--一般线的颜色-->
        <attr name="normal_text_color" format="color"/><!--一般文字的颜色-->
        <attr name="target_text_color" format="color"/><!--一般文字的颜色-->
        <attr name="passed_line_color" format="color"/><!--已经过线的颜色-->
        <attr name="step_count" format="integer"/><!--总step数-->
        <attr name="current_step" format="integer"/><!--当前step位置-->
        <attr name="normal_step_iv" format="reference"/><!--一般图片-->
        <attr name="passed_step_iv" format="reference"/><!--已经过的图片-->
        <attr name="target_step_iv" format="reference"/><!--当前step图片-->
        <attr name="step_is_touch" format="boolean"/><!--step是否可点-->
        <attr name="text_up_line" format="boolean"/><!--文字是否在线上-->
    </declare-styleable>
</resources>
        CheckBox cbTouch = findViewById(R.id.cb_touch);
        CheckBox cbIsDown = findViewById(R.id.cb_is_down);
        final StepView stepView = findViewById(R.id.step_view);
        String[] stepTexts = new String[]{"订单已提交", "商家已接单", "配送中", "已送达"};
        stepView.setStepTexts(stepTexts);//传入每一进度的文字描述
        stepView.setCurrentStep(2);//设置当前进度所在位置
        stepView.setOnItemStepTouchListener(new StepView.OnItemStepTouchListener() {
            @Override
            public void onItemStepTouch(int postion) {
                Log.d(TAG, "当前点击位置: "+postion);
            }
        });
        cbTouch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onChe
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值