├── .gitignore ├── .idea └── vcs.xml ├── README.MD ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xk │ │ └── sanjay │ │ └── rulerview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xk │ │ │ └── sanjay │ │ │ └── rulerview │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── icon_arrow.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── arrays.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── xk │ └── sanjay │ └── rulerview │ └── ExampleUnitTest.java ├── art ├── demo.png ├── demo3.png └── demo_up_half.png ├── build.gradle ├── gradle.properties ├── gradlew ├── gradlew.bat ├── rulberview ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xk │ │ └── sanjay │ │ └── rulberview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xk │ │ │ └── sanjay │ │ │ └── rulberview │ │ │ ├── RulerWheel.java │ │ │ └── WheelHorizontalScroller.java │ └── res │ │ ├── drawable-xxhdpi │ │ ├── ruler_mid_arraw.png │ │ └── ruler_mid_arraw_down.png │ │ └── values │ │ ├── arrays.xml │ │ ├── attrs_ruler.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── xk │ └── sanjay │ └── rulberview │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | 2 | # 介绍 3 | 4 | 5 | 这是一个水平的尺子滚轮插件 6 | 7 | ##上对齐+显示效果 8 | 9 | ![](art/demo.png) 10 | 11 | ##上对齐+折半显示效果 12 | 13 | ![UpModel_HalfModel](art/demo_up_half.png) 14 | 15 | ## 渐显效果 16 | 17 | ![UpModel_HalfModel](art/demo3.png) 18 | 19 | #特性 20 | 21 | 1. 支持定义字体的大小和颜色和是否显示刻度值 22 | 2. 支持定义各个刻度的颜色和大小,目前有大,中,小三者,如图片所示,有最大的是黑色,中等的为绿色,最小的是蓝色。同时刻度间隔和刻度的大小可以调节。 23 | 3. 支持自定义中间的指标器。 24 | 4. 可以有上和下,两种对齐的方式。 25 | 5. 支持指定默认值。 26 | 6. 支持设置最大和最小值。 27 | 7. 两种刻度格式SCALE和HALF,前者为有10格刻度,后者为只有0.5一格小的刻度。参考图片 28 | 8. 刻度尺的渐显效果 29 | 9. 支持显示自定义的数据! 30 | 10. 刻度值支持渐现的效果 31 | 11. 加入代码控制选中数据部分内容。 32 | 33 | 34 | # 考虑加入的新特性 35 | 36 | 1. 支持修改文字和刻度的间距定制 37 | 38 | 39 | # 使用方法 40 | 41 | ## XML 默认方式 42 | 43 | 44 | 73 | 74 | 75 | ## Activity 76 | 77 | rulerView = (RulerWheel) findViewById(R.id.ruler_view); 78 | rulerView.setScrollingListener(new RulerWheel.OnWheelScrollListener() { 79 | @Override 80 | public void onChanged(RulerWheel wheel, int oldValue, int newValue) { 81 | Log.e(TAG, "curValue=" + newValue); 82 | } 83 | 84 | @Override 85 | public void onScrollingStarted(RulerWheel wheel) { 86 | 87 | } 88 | 89 | @Override 90 | public void onScrollingFinished(RulerWheel wheel) { 91 | 92 | } 93 | }); 94 | 95 | # 鸣谢 96 | 特别感谢[獨行Zz](http://blog.csdn.net/dashu8193058/article/details/45846189),这个项目是在他基础上改的。 97 | 98 | 还有需要别的欢迎在这个基础自己定制 99 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.xk.sanjay.rulerview" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.1' 26 | compile 'com.android.support:design:23.1.1' 27 | compile project(path: ':rulberview') 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in F:\devel\Android_SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xk/sanjay/rulerview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xk.sanjay.rulerview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/xk/sanjay/rulerview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.xk.sanjay.rulerview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.widget.TextView; 6 | 7 | import com.xk.sanjay.rulberview.RulerWheel; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | 15 | private RulerWheel rulerView; 16 | private RulerWheel rulerView2; 17 | private String TAG = this.getClass().getSimpleName(); 18 | 19 | private TextView tvCurValue; 20 | private TextView tvCurValue2; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | List list = new ArrayList<>(); 28 | for (int i = 30; i < 150; i += 1) { 29 | list.add(i + ""); 30 | for (int j = 1; j < 10; j++) { 31 | list.add(i + "." + j); 32 | } 33 | } 34 | 35 | tvCurValue = (TextView) findViewById(R.id.curValue_tv); 36 | rulerView = (RulerWheel) findViewById(R.id.ruler_view); 37 | rulerView.setData(list); 38 | rulerView.setScrollingListener(new RulerWheel.OnWheelScrollListener() { 39 | @Override 40 | public void onChanged(RulerWheel wheel, String oldValue, String newValue) { 41 | tvCurValue.setText(newValue + ""); 42 | } 43 | 44 | @Override 45 | public void onScrollingStarted(RulerWheel wheel) { 46 | 47 | } 48 | 49 | @Override 50 | public void onScrollingFinished(RulerWheel wheel) { 51 | 52 | } 53 | }); 54 | 55 | 56 | List list2 = new ArrayList<>(); 57 | for (int i = 1000; i < 50000; i += 500) { 58 | list2.add(i + ""); 59 | } 60 | tvCurValue2 = (TextView) findViewById(R.id.curValue2_tv); 61 | rulerView2 = (RulerWheel) findViewById(R.id.ruler_view2); 62 | rulerView2.setData(list2); 63 | rulerView2.setDataModel(RulerWheel.DATA_SET); 64 | rulerView2.setSelectedValue("8000"); 65 | //不默认数据的画可以加下面的方式设置 66 | // rulerView2.setData(list2); 67 | rulerView2.setScrollingListener(new RulerWheel.OnWheelScrollListener() { 68 | @Override 69 | public void onChanged(RulerWheel wheel, String oldValue, String newValue) { 70 | tvCurValue2.setText(newValue + ""); 71 | } 72 | 73 | @Override 74 | public void onScrollingStarted(RulerWheel wheel) { 75 | 76 | } 77 | 78 | @Override 79 | public void onScrollingFinished(RulerWheel wheel) { 80 | 81 | } 82 | }); 83 | 84 | 85 | } 86 | 87 | 88 | public static void main(String[] args) { 89 | 90 | List list = new ArrayList<>(); 91 | for (int i = 10; i < 200; i += 1) { 92 | list.add(i + ""); 93 | for (int j = 1; j < 10; j++) { 94 | list.add(i + "." + j); 95 | } 96 | } 97 | System.out.println(String.valueOf(list)); 98 | 99 | 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 22 | 23 | 43 | 44 | 53 | 54 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanjay-F/RulerView/fc45621c9664a542aaf099a9a40e10ba33f29911/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/icon_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanjay-F/RulerView/fc45621c9664a542aaf099a9a40e10ba33f29911/app/src/main/res/mipmap-xhdpi/icon_arrow.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanjay-F/RulerView/fc45621c9664a542aaf099a9a40e10ba33f29911/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 1 7 | 3 8 | 5 9 | 11 10 | 13 11 | 19 12 | 30 13 | 46 14 | 90 15 | 104 16 | 247 17 | 422 18 | 500 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RulerView 3 | Settings 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |