Coder Social home page Coder Social logo

wheelview's Introduction

WheelView

基于RecycleView写的一个WheelView

show you the code

    dateWheel = (RecycleWheelView) findViewById(R.id.dateWheelView);
     
    dateWheel.setLabelTextColor(getResources().getColor(R.color.colorAccent));
    dateWheel.setLineColor(getResources().getColor(R.color.colorAccent));
    dateWheel.setVisibleItem(5);
    dateWheel.setLabel("cm");
    
    mAdapter = new WheelAdapter<>(this);
    List<String> dataList = new ArrayList<>();
    for (int i = 60; i < 240; i++) {
        dataList.add(String.format("%d", i));
    }
    mAdapter.setData(dataList);
    
    dateWheel.setAdapter(mAdapter);
    dateWheel.setSelectedItem(50);
    dateWheel.setOnSelectListener(new RecycleWheelView.OnSelectItemListener() {
            @Override
            public void onSelectChanged(int position) {
                mAdapter.setSelectedIndex(position);
                Toast.makeText(MainActivity.this, "index=" + position, Toast.LENGTH_SHORT).show();
            }
        });

目前支持的特性有

  1. 加标签,定制颜色,大小等效果。例如图片显示的年
  2. 设置是否渐显
  3. 设置是否缩小(curve)
  4. 显示的item数目
  5. 中间选中的颜色和没选中的原色不一样功能(用丑陋的回调方式解决了)

存在的问题

  1. 目前还不能自适应大小 就是当设置只显示3个时候,不能动态调节ChildView的大小
  2. 在设置为curve的时候,显示有些小问题,暂时不建议使用

wheelview's People

Contributors

sanjay-f 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.