Giter VIP home page Giter VIP logo

busline's Introduction

BusLine

仿《车来了》公交线路自定义View,根据线路数据绘制View并控制滑动手势。

效果

先看最终运行效果:

效果图

使用

  • XML布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_vertical_margin"
    android:paddingRight="@dimen/activity_vertical_margin"
    >

    <com.jacpy.busline.widget.BusLineView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/bus_line"
        android:background="@android:color/darker_gray"
        />

</RelativeLayout>
  • 在代码中使用:
BusLineView view = (BusLineView) findViewById(R.id.bus_line);
view.setBusLineData(initData()); // 设置数据
view.setOnBusStationClickListener(this); // 设置公交站点的点击事件
  • 性能 在2013年的机型MOTO G XT1032机子上运行,同时刷新96个公交站点数据,onDraw()方法耗时平均7ms左右。

实现原理

站点信息使用android系统中的绘图部分API,位置是通过大小及顺序计算位置坐标。手势滑动使用的是android系统中的Touch事件控制及Scroller滚动实现。

关于

jacpy

License

本项目遵守Apache 2.0 license。

busline's People

Contributors

jacpy 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.