├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── jp
│ │ └── shts
│ │ └── android
│ │ └── trianglelabelview
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── jp
│ │ │ └── shts
│ │ │ └── android
│ │ │ └── trianglelabelview
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable
│ │ ├── s_image_1.jpg
│ │ ├── s_image_2.jpg
│ │ ├── s_image_3.jpg
│ │ └── s_image_4.jpg
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── card_left_bottom.xml
│ │ ├── card_left_top.xml
│ │ ├── card_right_bottom.xml
│ │ ├── card_right_top.xml
│ │ └── content_main.xml
│ │ ├── menu
│ │ └── menu_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-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── color_material.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── jp
│ └── shts
│ └── android
│ └── trianglelabelview
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── img
└── capture.png
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── jp
│ │ └── shts
│ │ └── android
│ │ └── library
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── jp
│ │ │ └── shts
│ │ │ └── android
│ │ │ └── library
│ │ │ └── TriangleLabelView.java
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── jp
│ └── shts
│ └── android
│ └── library
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .idea/
7 | .DS_Store
8 | /build
9 | /captures
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | TriangleLabelView
2 | ====================
3 | Show triangle view.
4 |
5 | [](https://android-arsenal.com/details/1/3336)
6 |
7 | [](https://jitpack.io/#shts/TriangleLabelView)
8 |
9 |
10 |
11 |
12 |
13 | How to Use
14 | =====
15 |
16 | To see how the TriangleLabelView are added to your xml layouts, check the sample project.
17 |
18 | ```
19 |
35 |
36 | ```
37 |
38 | Install
39 | =====
40 |
41 | Add it in your root `build.gradle` at the end of repositories:
42 |
43 | ```groovy
44 | allprojects {
45 | repositories {
46 | ...
47 | maven { url "https://jitpack.io" }
48 | }
49 | }
50 | ```
51 | Add the dependency
52 |
53 | ```groovy
54 | dependencies {
55 | compile 'com.github.shts:TriangleLabelView:1.1.2'
56 | }
57 | ```
58 |
59 | Credits
60 | =======
61 | I used [LabelView](https://github.com/corerzhang/LabelView) library by [Corer](https://github.com/corerzhang) as a base for development.
62 |
63 | License
64 | =======
65 |
66 | Copyright (C) 2016 Shota Saito
67 |
68 | Licensed under the Apache License, Version 2.0 (the "License");
69 | you may not use this file except in compliance with the License.
70 | You may obtain a copy of the License at
71 |
72 | http://www.apache.org/licenses/LICENSE-2.0
73 |
74 | Unless required by applicable law or agreed to in writing, software
75 | distributed under the License is distributed on an "AS IS" BASIS,
76 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77 | See the License for the specific language governing permissions and
78 | limitations under the License.
79 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.1"
6 |
7 | defaultConfig {
8 | applicationId "jp.shts.android.trianglelabelview"
9 | minSdkVersion 10
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:24.2.0'
26 | compile 'com.android.support:design:24.2.0'
27 | compile 'com.android.support:cardview-v7:24.2.0'
28 | compile project(':library')
29 | }
30 |
--------------------------------------------------------------------------------
/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 /Applications/adt-bundle-mac-x86_64-20131030/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/jp/shts/android/trianglelabelview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package jp.shts.android.trianglelabelview;
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/jp/shts/android/trianglelabelview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package jp.shts.android.trianglelabelview;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.support.v7.widget.Toolbar;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
14 | toolbar.setTitle(R.string.app_name);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/s_image_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/drawable/s_image_1.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/s_image_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/drawable/s_image_2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/s_image_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/drawable/s_image_3.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/s_image_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/drawable/s_image_4.jpg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_left_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
16 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_left_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
16 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_right_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
16 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_right_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
16 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
20 |
25 |
30 |
31 |
36 |
41 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/app/src/main/res/mipmap-xxxhdpi/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/color_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
14 |
15 |
16 | #FFEBEE
17 | #FFCDD2
18 | #EF9A9A
19 | #E57373
20 | #EF5350
21 | #F44336
22 | #E53935
23 | #D32F2F
24 | #C62828
25 | #B71C1C
26 | #FF8A80
27 | #FF5252
28 | #FF1744
29 | #D50000
30 |
31 | #EDE7F6
32 | #D1C4E9
33 | #B39DDB
34 | #9575CD
35 | #7E57C2
36 | #673AB7
37 | #5E35B1
38 | #512DA8
39 | #4527A0
40 | #311B92
41 | #B388FF
42 | #7C4DFF
43 | #651FFF
44 | #6200EA
45 |
46 | #E1F5FE
47 | #B3E5FC
48 | #81D4FA
49 | #4FC3F7
50 | #29B6F6
51 | #03A9F4
52 | #039BE5
53 | #0288D1
54 | #0277BD
55 | #01579B
56 | #80D8FF
57 | #40C4FF
58 | #00B0FF
59 | #0091EA
60 |
61 | #E8F5E9
62 | #C8E6C9
63 | #A5D6A7
64 | #81C784
65 | #66BB6A
66 | #4CAF50
67 | #43A047
68 | #388E3C
69 | #2E7D32
70 | #1B5E20
71 | #B9F6CA
72 | #69F0AE
73 | #00E676
74 | #00C853
75 |
76 | #FFFDE7
77 | #FFF9C4
78 | #FFF59D
79 | #FFF176
80 | #FFEE58
81 | #FFEB3B
82 | #FDD835
83 | #FBC02D
84 | #F9A825
85 | #F57F17
86 | #FFFF8D
87 | #FFFF00
88 | #FFEA00
89 | #FFD600
90 |
91 | #FBE9E7
92 | #FFCCBC
93 | #FFAB91
94 | #FF8A65
95 | #FF7043
96 | #FF5722
97 | #F4511E
98 | #E64A19
99 | #D84315
100 | #BF360C
101 | #FF9E80
102 | #FF6E40
103 | #FF3D00
104 | #DD2C00
105 |
106 | #ECEFF1
107 | #CFD8DC
108 | #B0BEC5
109 | #90A4AE
110 | #78909C
111 | #607D8B
112 | #546E7A
113 | #455A64
114 | #37474F
115 | #263238
116 |
117 | #FCE4EC
118 | #F8BBD0
119 | #F48FB1
120 | #F06292
121 | #EC407A
122 | #E91E63
123 | #D81B60
124 | #C2185B
125 | #AD1457
126 | #880E4F
127 | #FF80AB
128 | #FF4081
129 | #F50057
130 | #C51162
131 |
132 | #E8EAF6
133 | #C5CAE9
134 | #9FA8DA
135 | #7986CB
136 | #5C6BC0
137 | #3F51B5
138 | #3949AB
139 | #303F9F
140 | #283593
141 | #1A237E
142 | #8C9EFF
143 | #536DFE
144 | #3D5AFE
145 | #304FFE
146 |
147 | #E0F7FA
148 | #B2EBF2
149 | #80DEEA
150 | #4DD0E1
151 | #26C6DA
152 | #00BCD4
153 | #00ACC1
154 | #0097A7
155 | #00838F
156 | #006064
157 | #84FFFF
158 | #18FFFF
159 | #00E5FF
160 | #00B8D4
161 |
162 | #F1F8E9
163 | #DCEDC8
164 | #C5E1A5
165 | #AED581
166 | #9CCC65
167 | #8BC34A
168 | #7CB342
169 | #689F38
170 | #558B2F
171 | #33691E
172 | #CCFF90
173 | #B2FF59
174 | #76FF03
175 | #64DD17
176 |
177 | #FFF8E1
178 | #FFECB3
179 | #FFE082
180 | #FFD54F
181 | #FFCA28
182 | #FFC107
183 | #FFB300
184 | #FFA000
185 | #FF8F00
186 | #FF6F00
187 | #FFE57F
188 | #FFD740
189 | #FFC400
190 | #FFAB00
191 |
192 | #EFEBE9
193 | #D7CCC8
194 | #BCAAA4
195 | #A1887F
196 | #8D6E63
197 | #795548
198 | #6D4C41
199 | #5D4037
200 | #4E342E
201 | #3E2723
202 |
203 | #F3E5F5
204 | #E1BEE7
205 | #CE93D8
206 | #BA68C8
207 | #AB47BC
208 | #9C27B0
209 | #8E24AA
210 | #7B1FA2
211 | #6A1B9A
212 | #4A148C
213 | #EA80FC
214 | #E040FB
215 | #D500F9
216 | #AA00FF
217 |
218 | #E3F2FD
219 | #BBDEFB
220 | #90CAF9
221 | #64B5F6
222 | #42A5F5
223 | #2196F3
224 | #1E88E5
225 | #1976D2
226 | #1565C0
227 | #0D47A1
228 | #82B1FF
229 | #448AFF
230 | #2979FF
231 | #2962FF
232 |
233 | #E0F2F1
234 | #B2DFDB
235 | #80CBC4
236 | #4DB6AC
237 | #26A69A
238 | #009688
239 | #00897B
240 | #00796B
241 | #00695C
242 | #004D40
243 | #A7FFEB
244 | #64FFDA
245 | #1DE9B6
246 | #00BFA5
247 |
248 | #F9FBE7
249 | #F0F4C3
250 | #E6EE9C
251 | #DCE775
252 | #D4E157
253 | #CDDC39
254 | #C0CA33
255 | #AFB42B
256 | #9E9D24
257 | #827717
258 | #F4FF81
259 | #EEFF41
260 | #C6FF00
261 | #AEEA00
262 |
263 | #FFF3E0
264 | #FFE0B2
265 | #FFCC80
266 | #FFB74D
267 | #FFA726
268 | #FF9800
269 | #FB8C00
270 | #F57C00
271 | #EF6C00
272 | #E65100
273 | #FFD180
274 | #FFAB40
275 | #FF9100
276 | #FF6D00
277 |
278 | #FAFAFA
279 | #F5F5F5
280 | #EEEEEE
281 | #E0E0E0
282 | #BDBDBD
283 | #9E9E9E
284 | #757575
285 | #616161
286 | #424242
287 | #212121
288 |
289 | #000000
290 | #FFFFFF
291 |
292 |
293 |
--------------------------------------------------------------------------------
/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 | TriangleLabelView
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/jp/shts/android/trianglelabelview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package jp.shts.android.trianglelabelview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.1.3'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/img/capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shts/TriangleLabelView/fb0a1df514ea37d39fabbfff93d08ca482cd2a48/img/capture.png
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | android {
5 | compileSdkVersion 24
6 | buildToolsVersion "24.0.1"
7 |
8 | defaultConfig {
9 | minSdkVersion 10
10 | targetSdkVersion 24
11 | versionCode 3
12 | versionName "1.1.1"
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:24.2.0'
26 | }
27 |
--------------------------------------------------------------------------------
/library/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 /Applications/adt-bundle-mac-x86_64-20131030/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 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/jp/shts/android/library/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package jp.shts.android.library;
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 | }
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/library/src/main/java/jp/shts/android/library/TriangleLabelView.java:
--------------------------------------------------------------------------------
1 | package jp.shts.android.library;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.annotation.TargetApi;
5 | import android.content.Context;
6 | import android.content.res.TypedArray;
7 | import android.graphics.Canvas;
8 | import android.graphics.Color;
9 | import android.graphics.Paint;
10 | import android.graphics.Path;
11 | import android.graphics.Rect;
12 | import android.graphics.Typeface;
13 | import android.os.Build;
14 | import android.support.annotation.ColorInt;
15 | import android.support.annotation.ColorRes;
16 | import android.support.annotation.StringRes;
17 | import android.support.v4.content.ContextCompat;
18 | import android.util.AttributeSet;
19 | import android.view.View;
20 |
21 | public class TriangleLabelView extends View {
22 |
23 | private static final String TAG = TriangleLabelView.class.getSimpleName();
24 |
25 | private static class PaintHolder {
26 | String text = "";
27 | Paint paint;
28 | int color;
29 | float size;
30 | float height;
31 | float width;
32 | int style;
33 |
34 | void initPaint() {
35 | paint = new Paint(Paint.ANTI_ALIAS_FLAG);
36 | paint.setColor(color);
37 | paint.setTextAlign(Paint.Align.CENTER);
38 | paint.setTextSize(size);
39 | if (style == 1) {
40 | paint.setTypeface(Typeface.SANS_SERIF);
41 | } else if (style == 2) {
42 | paint.setTypeface(Typeface.DEFAULT_BOLD);
43 | }
44 | }
45 |
46 | void resetStatus() {
47 | Rect rectText = new Rect();
48 | paint.getTextBounds(text, 0, text.length(), rectText);
49 | width = rectText.width();
50 | height = rectText.height();
51 | }
52 | }
53 |
54 | private PaintHolder primary = new PaintHolder();
55 | private PaintHolder secondary = new PaintHolder();
56 |
57 | private float topPadding;
58 | private float bottomPadding;
59 | private float centerPadding;
60 |
61 | private Paint trianglePaint;
62 | private int backGroundColor;
63 |
64 | private int width;
65 | private int height;
66 |
67 | private static final int DEGREES_LEFT = -45;
68 | private static final int DEGREES_RIGHT = 45;
69 |
70 | private Corner corner;
71 |
72 | public enum Corner {
73 | TOP_LEFT(1),
74 | TOP_RIGHT(2),
75 | BOTTOM_LEFT(3),
76 | BOTTOM_RIGHT(4),;
77 | private final int type;
78 |
79 | Corner(int type) {
80 | this.type = type;
81 | }
82 |
83 | private boolean top() {
84 | return this == TOP_LEFT || this == TOP_RIGHT;
85 | }
86 |
87 | private boolean left() {
88 | return this == TOP_LEFT || this == BOTTOM_LEFT;
89 | }
90 |
91 | private static Corner from(int type) {
92 | for (Corner c : values()) {
93 | if (c.type == type) return c;
94 | }
95 | return Corner.TOP_LEFT;
96 | }
97 | }
98 |
99 | public TriangleLabelView(Context context) {
100 | this(context, null);
101 | }
102 |
103 | public TriangleLabelView(Context context, AttributeSet attrs) {
104 | this(context, attrs, 0);
105 | }
106 |
107 | public TriangleLabelView(Context context, AttributeSet attrs, int defStyleAttr) {
108 | super(context, attrs, defStyleAttr);
109 | init(context, attrs);
110 | }
111 |
112 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
113 | public TriangleLabelView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
114 | super(context, attrs, defStyleAttr, defStyleRes);
115 | init(context, attrs);
116 | }
117 |
118 | private void init(Context context, AttributeSet attrs) {
119 | TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TriangleLabelView);
120 |
121 | this.topPadding = ta.getDimension(R.styleable.TriangleLabelView_labelTopPadding, dp2px(7));
122 | this.centerPadding = ta.getDimension(R.styleable.TriangleLabelView_labelCenterPadding, dp2px(3));
123 | this.bottomPadding = ta.getDimension(R.styleable.TriangleLabelView_labelBottomPadding, dp2px(3));
124 |
125 | this.backGroundColor = ta.getColor(R.styleable.TriangleLabelView_backgroundColor, Color.parseColor("#66000000"));
126 | this.primary.color = ta.getColor(R.styleable.TriangleLabelView_primaryTextColor, Color.WHITE);
127 | this.secondary.color = ta.getColor(R.styleable.TriangleLabelView_secondaryTextColor, Color.WHITE);
128 |
129 | this.primary.size = ta.getDimension(R.styleable.TriangleLabelView_primaryTextSize, sp2px(11));
130 | this.secondary.size = ta.getDimension(R.styleable.TriangleLabelView_secondaryTextSize, sp2px(8));
131 |
132 | final String primary = ta.getString(R.styleable.TriangleLabelView_primaryText);
133 | if (primary != null) {
134 | this.primary.text = primary;
135 | }
136 | final String secondary = ta.getString(R.styleable.TriangleLabelView_secondaryText);
137 | if (secondary != null) {
138 | this.secondary.text = secondary;
139 | }
140 |
141 | this.primary.style = ta.getInt(R.styleable.TriangleLabelView_primaryTextStyle, 2);
142 | this.secondary.style = ta.getInt(R.styleable.TriangleLabelView_secondaryTextStyle, 0);
143 |
144 | this.corner = Corner.from(ta.getInt(R.styleable.TriangleLabelView_corner, 1));
145 |
146 | ta.recycle();
147 |
148 | this.primary.initPaint();
149 | this.secondary.initPaint();
150 |
151 | trianglePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
152 | trianglePaint.setColor(backGroundColor);
153 |
154 | this.primary.resetStatus();
155 | this.secondary.resetStatus();
156 | }
157 |
158 | public void setLabelTopPadding(float dp) {
159 | topPadding = dp2px(dp);
160 | }
161 |
162 | public float getLabelTopPadding() {
163 | return topPadding;
164 | }
165 |
166 | public void setLabelCenterPadding(float dp) {
167 | centerPadding = dp2px(dp);
168 | relayout();
169 | }
170 |
171 | public float getLabelCenterPadding() {
172 | return centerPadding;
173 | }
174 |
175 | public void setLabelBottomPadding(float dp) {
176 | bottomPadding = dp2px(dp);
177 | relayout();
178 | }
179 |
180 | public float getLabelBottomPadding() {
181 | return bottomPadding;
182 | }
183 |
184 | public void setPrimaryText(String text) {
185 | primary.text = text;
186 | primary.resetStatus();
187 | relayout();
188 | }
189 |
190 | public void setPrimaryText(@StringRes int textRes) {
191 | primary.text = getContext().getString(textRes);
192 | primary.resetStatus();
193 | relayout();
194 | }
195 |
196 | public String getPrimaryText() {
197 | return primary.text;
198 | }
199 |
200 | public void setSecondaryText(String smallText) {
201 | secondary.text = smallText;
202 | secondary.resetStatus();
203 | relayout();
204 | }
205 |
206 | public void setSecondaryText(@StringRes int textRes) {
207 | secondary.text = getContext().getString(textRes);
208 | secondary.resetStatus();
209 | relayout();
210 | }
211 |
212 | public String getSecondaryText() {
213 | return secondary.text;
214 | }
215 |
216 | public void setPrimaryTextColor(@ColorInt int color) {
217 | primary.color = color;
218 | primary.initPaint();
219 | primary.resetStatus();
220 | relayout();
221 | }
222 |
223 | public void setPrimaryTextColorResource(@ColorRes int colorResource) {
224 | primary.color = ContextCompat.getColor(getContext(), colorResource);
225 | primary.initPaint();
226 | primary.resetStatus();
227 | relayout();
228 | }
229 |
230 | public void setSecondaryTextColor(@ColorInt int color) {
231 | secondary.color = color;
232 | secondary.initPaint();
233 | secondary.resetStatus();
234 | relayout();
235 | }
236 |
237 | public void setSecondaryTextColorResource(@ColorRes int colorResource) {
238 | secondary.color = ContextCompat.getColor(getContext(), colorResource);
239 | secondary.initPaint();
240 | secondary.resetStatus();
241 | relayout();
242 | }
243 |
244 | public void setPrimaryTextSize(float sp) {
245 | primary.size = sp2px(sp);
246 | relayout();
247 | }
248 |
249 | public void setSecondaryTextSize(float sp) {
250 | secondary.size = sp2px(sp);
251 | relayout();
252 | }
253 |
254 | public float getPrimaryTextSize() {
255 | return primary.size;
256 | }
257 |
258 | public float getSecondaryTextSize() {
259 | return secondary.size;
260 | }
261 |
262 | public void setTriangleBackgroundColor(@ColorInt int color) {
263 | backGroundColor = color;
264 | trianglePaint.setColor(backGroundColor);
265 | relayout();
266 | }
267 |
268 | public void setTriangleBackgroundColorResource(@ColorRes int colorResource) {
269 | backGroundColor = ContextCompat.getColor(getContext(), colorResource);
270 | trianglePaint.setColor(backGroundColor);
271 | relayout();
272 | }
273 |
274 | public int getTriangleBackGroundColor() {
275 | return backGroundColor;
276 | }
277 |
278 | public void setCorner(Corner corner) {
279 | this.corner = corner;
280 | relayout();
281 | }
282 |
283 | public Corner getCorner() {
284 | return corner;
285 | }
286 |
287 | @Override
288 | protected void onDraw(Canvas canvas) {
289 | super.onDraw(canvas);
290 | canvas.save();
291 |
292 | // translate
293 | if (corner.top()) {
294 | canvas.translate(0, (float) ((height * Math.sqrt(2)) - height));
295 | }
296 |
297 | // rotate
298 | if (corner.top()) {
299 | if (corner.left()) {
300 | canvas.rotate(DEGREES_LEFT, 0, height);
301 | } else {
302 | canvas.rotate(DEGREES_RIGHT, width, height);
303 | }
304 | } else {
305 | if (corner.left()) {
306 | canvas.rotate(DEGREES_RIGHT, 0, 0);
307 | } else {
308 | canvas.rotate(DEGREES_LEFT, width, 0);
309 | }
310 | }
311 |
312 | // draw triangle
313 | @SuppressLint("DrawAllocation")
314 | Path path = new Path();
315 | if (corner.top()) {
316 | path.moveTo(0, height);
317 | path.lineTo(width / 2, 0);
318 | path.lineTo(width, height);
319 | } else {
320 | path.moveTo(0, 0);
321 | path.lineTo(width / 2, height);
322 | path.lineTo(width, 0);
323 | }
324 | path.close();
325 | canvas.drawPath(path, trianglePaint);
326 |
327 | // draw secondaryText
328 | if (corner.top()) {
329 | canvas.drawText(secondary.text, (width) / 2, topPadding + secondary.height, secondary.paint);
330 | canvas.drawText(primary.text, (width) / 2, (topPadding + secondary.height + centerPadding + primary.height), primary.paint);
331 | } else {
332 | canvas.drawText(secondary.text, (width) / 2, bottomPadding + secondary.height + centerPadding + primary.height, secondary.paint);
333 | canvas.drawText(primary.text, (width) / 2, (bottomPadding + primary.height), primary.paint);
334 | }
335 | canvas.restore();
336 | }
337 |
338 | @Override
339 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
340 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
341 | height = (int) (topPadding + centerPadding + bottomPadding + secondary.height + primary.height);
342 | width = 2 * height;
343 | int realHeight = (int) (height * Math.sqrt(2));
344 | setMeasuredDimension(width, realHeight);
345 | }
346 |
347 | public int dp2px(float dpValue) {
348 | final float scale = getContext().getResources().getDisplayMetrics().density;
349 | return (int) (dpValue * scale + 0.5f);
350 | }
351 |
352 | public float sp2px(float spValue) {
353 | final float scale = getContext().getResources().getDisplayMetrics().scaledDensity;
354 | return spValue * scale;
355 | }
356 |
357 | /**
358 | * Should be called whenever what we're displaying could have changed.
359 | */
360 | private void relayout() {
361 | invalidate();
362 | requestLayout();
363 | }
364 | }
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/test/java/jp/shts/android/library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package jp.shts.android.library;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------