自定义滚动刻度尺控件

自定义滑动刻度尺

目前支持的自定义属性

<declare-styleable name="ScaleView">
    <!-- 基线是否显示 -->
    <attr name="baseLineEnable" format="boolean" />
    <!-- 基线的颜色 -->
    <attr name="baseLineColor" format="reference|color" />
    <!-- 基线的高度 -->
    <attr name="baseLineHeight" format="dimension" />
    <!-- 基线与底部的间距 -->
    <attr name="baseLineMarginBottom" format="dimension" />

    <!-- 刻度尺两侧空白区域的刻度线是否显示 -->
    <attr name="scaleLineExtendEnable" format="boolean" />
    <!-- 刻度线的颜色 -->
    <attr name="scaleLineColor" format="reference|color" />
    <!-- 刻度线的宽度 -->
    <attr name="scaleLineWidth" format="dimension" />
    <!-- 刻度值的颜色 -->
    <attr name="scaleLineTextColor" format="reference|color" />
    <!-- 刻度值字体大小 -->
    <attr name="scaleLineTextSize" format="dimension" />
    <!-- 刻度线间的宽度 -->
    <attr name="scaleLineSpaceWidth" format="dimension" />
    <!-- 刻度线间的子区间数 -->
    <attr name="scaleLineSubSpaceCount" format="integer" />

    <!-- 标线是否显示 -->
    <attr name="markLineEnable" format="boolean" />
    <!-- 标线的颜色 -->
    <attr name="markLineColor" format="reference|color" />
    <!-- 标线的宽度 -->
    <attr name="markLineWidth" format="dimension" />
    <!-- 标线顶部托盘的颜色 -->
    <attr name="markLineTrayColor" format="reference|color" />
    <!-- 标线顶部托盘的样式 -->
    <attr name="markLineTrayStyle">
        <enum name="none" value="0" />
        <enum name="solid_line" value="1" />
        <enum name="dotted_line" value="2" />
        <enum name="inverted_triangle" value="3" />
    </attr>
    <!-- 标线值的颜色 -->
    <attr name="markLineTextColor" format="reference|color" />
    <!-- 标线值字体大小 -->
    <attr name="markLineTextSize" format="dimension" />
    <!-- 显示标线值时,对应的刻度值是否隐藏 -->
    <attr name="markLineRetainScaleLineValueEnable" format="boolean" />
</declare-styleable>

初始化刻度值及默认下标

QScaleView scaleView = findViewById(R.id.select_scale_widget);
scaleView.setScaleInfo(list, 0);

获取当前的刻度值及下标

scaleView.setOnScaleChangeListener(new QScaleView.OnScaleChangeListener() {
    @Override
    public void onScaleChange(String scale, int position) {
        Log.e("QTest", "view  ->  scale:  " + scale + "  position:  " + position);
    }
});

Github地址

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值