1. 程式人生 > >Android:身高、體重橫向滾動刻度尺選擇器

Android:身高、體重橫向滾動刻度尺選擇器

身高、體重橫向滾動刻度尺選擇器

更新:

1、增加體重支援小數點的選擇方式的自定義View

<com.lost.zou.scaleruler.view.DecimalScaleRulerView
            android:id="@+id/ruler_weight"
            android:layout_width="match_parent"
            android:layout_height="58dp"
            android:layout_alignParentBottom="true" />
mWeightRulerView.setParam(DrawUtil.dip2px(10), DrawUtil.dip2px(32), DrawUtil.dip2px(24),
                DrawUtil.dip2px(14), DrawUtil.dip2px(9), DrawUtil.dip2px(12));
        mWeightRulerView.initViewParam(mWeight, 20.0f, 200.0f, 1);
        mWeightRulerView.setValueChangeListener(new DecimalScaleRulerView.OnValueChangeListener() {
            @Override
            public void onValueChange(float value) {
                mWeightValueTwo.setText(value + "kg");
                mWeight = value;
            }
        });

2、增加一個傾斜的TextView的自定義View實現:

<com.lost.zou.scaleruler.view.SlantedTextView
            android:layout_width="48dp"
            android:layout_height="48dp"
            app:slantedBackgroundColor="@color/colorPrimary"
            app:slantedLength="28dp"
            app:slantedMode="left"
            app:slantedText="體重"
            app:slantedTextColor="#ffffff"
            app:slantedTextSize="14sp" />

使用:

<com.lost.zou.scaleruler.view.ScaleRulerView
        android:id="@+id/scaleWheelView_height"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:layout_marginTop="36dp"
        android:background="@android:color/white"
        android:paddingLeft="30dp"
        android:paddingRight="30dp" />

效果圖如下:


image

image

image

image