├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── README.md ├── ScaleView.iml ├── app ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── lichfaker │ │ └── views │ │ └── scaleview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── lichfaker │ │ │ └── views │ │ │ └── scaleview │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── lichfaker │ └── views │ └── scaleview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images └── scale.gif ├── scaleview ├── build.gradle ├── proguard-rules.pro ├── scaleview.iml └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── lichfaker │ │ └── scaleview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── lichfaker │ │ │ └── scaleview │ │ │ ├── BaseScaleView.java │ │ │ ├── HorizontalScaleScrollView.java │ │ │ └── VerticalScaleScrollView.java │ └── res │ │ └── values │ │ ├── scale_attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── lichfaker │ └── scaleview │ └── ExampleUnitTest.java └── settings.gradle /.idea/.name: -------------------------------------------------------------------------------- 1 | ScaleView -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 25 | 26 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ScaleScrollView 2 | ====== 3 | 一个动态Draw的滚动刻度尺。 4 | 5 | ![](./images/scale.gif) 6 | 7 | Usage 8 | ----- 9 | 1. 在xml布局文件中引入: 10 | ``` 11 | 21 | ``` 22 | 23 | - 目前支持的自定义属性: 24 | * `scale_view_max` 最大值 25 | - `scale_view_min` 最小值 26 | - `scale_view_height` 刻度的高度 27 | - `scale_view_margin` 刻度的间距 28 | - `layout_width` 可动态调整 29 | 30 | - 获取当前的刻度值 31 | ``` 32 | scaleScrollView.setOnScrollListener(new OnScrollListener() { 33 | @Override 34 | public void onScaleScroll(int scale) { 35 | mTvHorizontalScale.setText("" + scale); 36 | } 37 | }); 38 | ``` 39 | 40 | Download 41 | ---- 42 | Gradle: 43 | ``` 44 | allprojects { 45 | repositories { 46 | ... 47 | maven { url "https://jitpack.io" } 48 | } 49 | } 50 | 51 | dependencies { 52 | compile 'com.github.LichFaker:ScaleView:-SNAPSHOT' 53 | } 54 | ``` 55 | 56 | 57 | License 58 | -------- 59 | 60 | Copyright 2016 LichFaker 61 | 62 | Licensed under the Apache License, Version 2.0 (the "License"); 63 | you may not use this file except in compliance with the License. 64 | You may obtain a copy of the License at 65 | 66 | http://www.apache.org/licenses/LICENSE-2.0 67 | 68 | Unless required by applicable law or agreed to in writing, software 69 | distributed under the License is distributed on an "AS IS" BASIS, 70 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 71 | See the License for the specific language governing permissions and 72 | limitations under the License. 73 | 74 | -------------------------------------------------------------------------------- /ScaleView.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.lichfaker.views.scaleview" 9 | minSdkVersion 14 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(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.0' 26 | compile project(':scaleview') 27 | } 28 | -------------------------------------------------------------------------------- /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 /Users/lichfaker/Library/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/lichfaker/views/scaleview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.lichfaker.views.scaleview; 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 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/lichfaker/views/scaleview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.lichfaker.views.scaleview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | import android.widget.EditText; 7 | import android.widget.TextView; 8 | 9 | import com.lichfaker.scaleview.HorizontalScaleScrollView; 10 | import com.lichfaker.scaleview.VerticalScaleScrollView; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | EditText mTvHorizontalScale; 15 | TextView mTvVerticalScale; 16 | HorizontalScaleScrollView scaleScrollView; 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | 23 | mTvHorizontalScale = (EditText) findViewById(R.id.horizontalScaleValue); 24 | 25 | scaleScrollView = (HorizontalScaleScrollView) findViewById(R.id.horizontalScale); 26 | scaleScrollView.setOnScrollListener(new HorizontalScaleScrollView.OnScrollListener() { 27 | @Override 28 | public void onScaleScroll(int scale) { 29 | mTvHorizontalScale.setText("" + scale); 30 | } 31 | }); 32 | 33 | findViewById(R.id.horizontalScaleValueBtn).setOnClickListener(new View.OnClickListener() { 34 | @Override 35 | public void onClick(View v) { 36 | String valStr = mTvHorizontalScale.getText().toString().trim(); 37 | scaleScrollView.setCurScale(Integer.parseInt(valStr)); 38 | } 39 | }); 40 | 41 | mTvVerticalScale = (TextView) findViewById(R.id.verticalScaleValue); 42 | 43 | VerticalScaleScrollView vScaleScrollView = (VerticalScaleScrollView) findViewById(R.id.verticalScale); 44 | vScaleScrollView.setOnScrollListener(new HorizontalScaleScrollView.OnScrollListener() { 45 | @Override 46 | public void onScaleScroll(int scale) { 47 | mTvVerticalScale.setText("" + scale); 48 | } 49 | }); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 25 | 26 | 34 | 35 |