├── settings.gradle ├── project.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── app ├── src │ └── main │ │ ├── res │ │ ├── drawable-nodpi │ │ │ ├── flag_uk.png │ │ │ ├── flag_us.png │ │ │ └── android1.jpg │ │ ├── drawable-hdpi │ │ │ ├── ic_warning.png │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ ├── ic_warning.png │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_warning.png │ │ ├── values │ │ │ ├── strings.xml │ │ │ └── attrs.xml │ │ ├── drawable │ │ │ └── background.xml │ │ └── layout │ │ │ ├── compound.xml │ │ │ ├── double_image.xml │ │ │ ├── box.xml │ │ │ ├── aspect.xml │ │ │ ├── entry_form.xml │ │ │ └── box_small.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── example │ │ └── customview │ │ ├── BoxGridActivity.java │ │ ├── AspectImageActivity.java │ │ ├── DoubleImageActivity.java │ │ ├── CompoundControlActivity.java │ │ ├── MainActivity.java │ │ └── widget │ │ ├── EntryFormView.java │ │ ├── AspectImageView.java │ │ ├── BoxGridLayout.java │ │ └── DoubleImageView.java └── build.gradle ├── .gitignore ├── README.md ├── gradlew.bat └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by IntelliJ IDEA 2 | # Project target. 3 | target=android-15 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/flag_uk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-nodpi/flag_uk.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/flag_us.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-nodpi/flag_us.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-hdpi/ic_warning.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-mdpi/ic_warning.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/android1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-nodpi/android1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devunwired/custom-view-examples/HEAD/app/src/main/res/drawable-xhdpi/ic_warning.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | CustomViewSamples 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Mar 20 13:12:07 MDT 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.2.1-all.zip 7 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | android { 4 | compileSdkVersion 15 5 | buildToolsVersion "20.0.0" 6 | 7 | defaultConfig { 8 | applicationId "com.example.customview" 9 | minSdkVersion 15 10 | targetSdkVersion 15 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | build/ 16 | 17 | # Local configuration file (sdk path, etc) 18 | local.properties 19 | 20 | # Eclipse project files 21 | .classpath 22 | .project 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Intellij project files 28 | *.iml 29 | *.ipr 30 | *.iws 31 | .idea/ 32 | .gradle -------------------------------------------------------------------------------- /app/src/main/res/drawable/background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 8 | 11 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/compound.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/double_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/box.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Custom View Examples# 2 | 3 | This repository contains a series of sample code designed to highlight applications of creating custom Views and ViewGroups. Examples include: 4 | 5 | - Custom widget measurement 6 | - Compound control 7 | - Custom View 8 | - Custom ViewGroup 9 | 10 | ##License## 11 | 12 | **The code supplied here is covered under the MIT Open Source License:** 13 | 14 | Copyright (c) 2013 Wireless Designs, LLC 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining 17 | a copy of this software and associated documentation files (the 18 | "Software"), to deal in the Software without restriction, including 19 | without limitation the rights to use, copy, modify, merge, publish, 20 | distribute, sublicense, and/or sell copies of the Software, and to 21 | permit persons to whom the Software is furnished to do so, subject to 22 | the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be 25 | included in all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 29 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 30 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 31 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 32 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 33 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/aspect.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 15 | 21 | 27 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/customview/BoxGridActivity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 Wireless Designs, LLC 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | package com.example.customview; 24 | 25 | import android.app.Activity; 26 | import android.os.Bundle; 27 | 28 | public class BoxGridActivity extends Activity { 29 | 30 | public void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.box); 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/customview/AspectImageActivity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 Wireless Designs, LLC 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | package com.example.customview; 24 | 25 | import android.app.Activity; 26 | import android.os.Bundle; 27 | 28 | public class AspectImageActivity extends Activity { 29 | 30 | public void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.aspect); 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/customview/DoubleImageActivity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 Wireless Designs, LLC 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | package com.example.customview; 24 | 25 | import android.app.Activity; 26 | import android.os.Bundle; 27 | 28 | public class DoubleImageActivity extends Activity { 29 | 30 | public void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.double_image); 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/entry_form.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 19 | 20 | 29 | 37 | 38 |