Giter Site home page Giter Site logo

liuxuanhai / ruleview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cstor-cdeep/ruleview

0.0 2.0 0.0 2.68 MB

Android自定义标尺控件(选择身高、体重等)

Home Page: http://www.jianshu.com/users/61f41588151d/latest_articles

Java 100.00%

ruleview's Introduction

RuleView

尺子刻度 -- 自定义view ###自定义view学习(第一章)


1、自定义刻度尺控件

在我们想要获取用户的身高体重等信息时,直接让他们输入显然不够友好偶然看到一款App用了类似刻度尺的界面让用户选择,觉得很赞。所有决定实现下。 实现的最终效果如下图所示:

7c0d4213-1242-496b-9898-0d04d14f3097.gif


#####2、使用方式

######2.1 在gradle添加依赖

compile 'com.zkk.view:ZkkRulerView:1.0.0'

######2.2 在xml中设置

<com.zkk.view.rulerview.RulerView
	android:id="@+id/ruler_height"
	android:layout_width="fill_parent"
	android:layout_height="58.0dip"
	android:layout_marginTop="24.0dip"
	app:alphaEnable="true"
	app:lineColor="@color/gray"
	app:lineMaxHeight="40dp"
	app:lineMidHeight="30dp"
	app:lineMinHeight="20dp"
	app:lineSpaceWidth="10dp"
	app:lineWidth="2dip"
	app:textColor="@color/black"
	app:minValue="80.0"
	app:maxValue="250.0"
	app:perValue="1"
	app:selectorValue="165.0"
	/>

######2.3 在activity中只需调用一个方法和一个数值的回调

 ruler_height=(RulerView)findViewById(R.id.ruler_height);
 ruler_weight.setOnValueChangeListener(new RulerView.OnValueChangeListener() {
            @Override
            public void onValueChange(float value) {
                tv_register_info_weight_value.setText(value+"");
            }
        });

/**
     * 
     * @param selectorValue 未选择时 默认的值 滑动后表示当前中间指针正在指着的值
     * @param minValue   最大数值
     * @param maxValue   最小的数值
     * @param per   最小单位  如 1:表示 每2条刻度差为1.   0.1:表示 每2条刻度差为0.1 在demo中 身高mPerValue为1  体重mPerValue 为0.1
     */
ruler_weight.setValue(165, 80, 250, 1); 

3、实现讲解

博客地址: http://www.jianshu.com/p/5d1fa50298b3

ruleview's People

Contributors

panacena avatar

Watchers

James Cloos avatar C++ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.