Code Monkey home page Code Monkey logo

wheelview's Introduction

WheelView

实现转轮的选择功能,效果见下图:

效果图

本项目是由这个项目修改而成,由于我做的改动实在太大了,基本上除了原来的大体框架以外,内部的实现逻辑全都做了大量修改,所以我另开了一个项目,但必须感谢原作者给我的启发。

先说说我所做的优化和改善吧:

  1. 滑动更加流畅顺滑;
  2. 可以点击实现单步的增减;
  3. 滑动过程中触摸立即停止滑动;
  4. 滑动的距离跟滑动的速度成正比,和滑动的时间成反比;
  5. 实现循环滚动,并可以切换

How To Use

add to your build.gradle files:

dependencies {
    compile 'com.pl:wheelview:0.7.2'
}

以下内容来自原项目,毕竟连代码都copy了,这些细节也懒得在乎了

Attributes

attr 属性 description 描述
lineColor divider line color 分割线颜色
lineHeight divider line height 分割线高度
itemNumber wheelview show item count 此wheelView显示item的个数
noEmpty if set true select area can't be null(empty),or could be empty 设置true则选中不能为空,否则可以是空
normalTextColor unSelected Text color 未选中文本颜色
normalTextSize unSelected Text size 未选中文本字体大小
selectedTextColor selected Text color 选中文本颜色
selectedTextSize selected Text size 选中文本字体大小
unitHeight item unit height 每个item单元的高度
isCyclic if scroll cyclic 是否循环滚动
maskDarkColor color of mask far from the select end 离选中位置远的遮罩颜色
maskLightColor color of mask near the select end 离选中位置近的遮罩颜色

Method

1. setData(ArrayList data)

set WheelView data
设置WheelView的数据

2. refreshData(ArrayList data)

refresh WheelView data ,and draw again
刷新 WheelView的数据,并重绘

3. int getSelected()

get selected item index
获取选中项的index

4. String getSelectedText()

get selected item text
获取选中项的文本信息

5. boolean isScrolling

is WheelView is scrolling
获取WheelView是否在滚动中

6. boolean isEnable()

is WheelView is enable
获取wheelView是否可用

7. void setEnable(boolean isEnable)

set WheelView enable
设置WheelView是否可用

8. void setDefault(int index)

set default selected index
设置默认选中项的index

9. int getListSize()

get WheelView item count
获取WheelView的item项个数

10. String getItemText(int index)

get the text by index
获取index位置上的文本数据

11. void setOnSelectListener(OnSelectListener onSelectListener)

set listener on WheelView that can get info when WheelView is scrolling or stop scroll.
对WheelView设置监听,在 滑动过程 或者 滑动停止 返回数据信息。

12. void setItemNumber(int itemNumber)

set the number ofitem show in WheelView
设置WheelView展示的项目数量

13. int getItemNumber()

get the number ofitem show in WheelView
获取WheelView展示的项目数量

14. void setCyclic(boolean cyclic)

set if scroll cyclic 设置是否循环滚动

15. boolean isCyclic()

get if scroll cyclic 获取是否循环滚动

具体的一些构思和设计思路,参见这篇文章这篇文章

wheelview's People

Contributors

penglu20 avatar

Watchers

 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.