├── .gitignore ├── CHANGELOG.md ├── LICENSE.txt ├── README.md ├── art ├── boroughs-framed-all.png ├── boroughs-framed-galaxy_mini.png ├── boroughs-framed-galaxy_nexus.png ├── boroughs-framed-nexus7.png ├── boroughs-framed-nexus_s.png ├── boroughs-framed_xoom.png ├── hi_res_icon.png ├── readme_pic.png ├── snapshot0.png └── snapshot1.png ├── build.gradle ├── gradle.properties ├── library ├── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── project.properties ├── res │ └── values │ │ └── il__attrs.xml └── src │ └── com │ └── manuelpeinado │ └── imagelayout │ ├── ImageFitter.java │ └── ImageLayout.java ├── maven_push.gradle ├── sample ├── AndroidManifest.xml ├── build.gradle ├── project.properties ├── res │ ├── drawable-hdpi │ │ ├── boroughs.png │ │ ├── curiosity.jpg │ │ ├── ic_launcher.png │ │ └── manhattan.jpg │ ├── drawable-mdpi │ │ ├── boroughs.png │ │ ├── curiosity.jpg │ │ ├── ic_launcher.png │ │ └── manhattan.jpg │ ├── drawable-xhdpi │ │ ├── boroughs.png │ │ ├── curiosity.jpg │ │ ├── ic_launcher.png │ │ └── manhattan.jpg │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── layout │ │ ├── activity_add_children_programmatically.xml │ │ ├── activity_basic_usage.xml │ │ ├── activity_change_image_dynamically.xml │ │ ├── activity_fit_attribute.xml │ │ ├── activity_home.xml │ │ └── activity_horizontal_scroll_view.xml │ ├── menu │ │ └── activity_fit_attribute.xml │ ├── values-large │ │ └── dimens.xml │ ├── values-small │ │ └── dimens.xml │ ├── values-v11 │ │ └── themes.xml │ ├── values-v14 │ │ └── themes.xml │ ├── values-xlarge │ │ └── dimens.xml │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ ├── styles.xml │ │ └── themes.xml └── src │ └── com │ └── manuelpeinado │ └── imagelayout │ └── demo │ ├── ActivityInfo.java │ ├── AddChildrenProgrammaticallyActivity.java │ ├── BasicUsageActivity.java │ ├── ChangeImageDynamicallyActivity.java │ ├── FitAttributeActivity.java │ ├── HomeActivity.java │ └── HorizontalScrollViewActivity.java └── settings.gradle /.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 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Android Studio 23 | *.iml 24 | .idea/ 25 | 26 | #Maven 27 | target 28 | release.properties 29 | pom.xml.* 30 | 31 | # Folder containing all the Google Play APKs 32 | apks 33 | 34 | # Gradle 35 | build 36 | .gradle 37 | sample/signing.properties 38 | 39 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Change Log 2 | ========== 3 | Version 1.1.0 *(2014-04-10)* 4 | ---------------------------- 5 | * Improved support for Gradle/Android Studio 6 | * Allow changing image dynamically 7 | 8 | Version 1.0.5 *(2014-02-20)* 9 | ---------------------------- 10 | * Migrated from maven to gradle 11 | 12 | Version 1.0.4 *(2014-01-12)* 13 | ---------------------------- 14 | * Added new "Horizontal ScrollView" sample 15 | 16 | Version 1.0.3 *(2013-04-01)* 17 | ---------------------------- 18 | * Fixed bug in "fit attribute" sample 19 | * Added to maven central 20 | * 21 | Version 1.0.2 *(2013-03-31)* 22 | ---------------------------- 23 | * Enhanced "fit" attribute with new value "both" 24 | * Added sample that showcases the different values of the "fit" attribute 25 | * Added ajustment of view size based on image aspect ratio 26 | * Added maven support 27 | 28 | Version 1.0.1 29 | ---------------------------- 30 | Skipped 31 | 32 | Version 1.0.0 *(2013-03-29)* 33 | ---------------------------- 34 | Initial release. 35 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ImageLayout 2 | =========== 3 | 4 | A layout that arranges its children in relation to a background image. The layout of each child is specified in image coordinates (pixels), and the conversion to screen coordinates is performed automatically. 5 | 6 | The background image is adjusted so that it fills the available space. 7 | 8 | For some applications this might be a useful replacement for the now deprecated AbsoluteLayout. 9 | 10 | ![Example Image][1] 11 | 12 | Try out the sample application: 13 | 14 | 15 | Android app on Google Play 17 | 18 | 19 | Or browse the [source code of the sample application][2] for a complete example of use. 20 | 21 | Including in your project 22 | ------------------------- 23 | 24 | If you’re using Eclipse with the ADT plugin you can include ImageLayout as a library project. Just create a new Android project in Eclipse using the library/ folder as the existing source, and add a reference to it to your application project. 25 | 26 | If you use gradle to build your Android project you can simply add a dependency for this library: 27 | 28 | ``` 29 | 30 | dependencies { 31 | mavenCentral() 32 | compile 'com.github.manuelpeinado.imagelayout:imagelayout:1.1.0' 33 | } 34 | 35 | ``` 36 | 37 | Usage 38 | ----- 39 | 40 | ### Adding to your layout 41 | 42 | 43 | Add an element named com.manuelpeinado.imagelayout.ImageLayout to your XML layout. This element should have the following attributes: 44 | 45 | | Attribute | Description | 46 | |------------------------|------------------------------------| 47 | | custom:image | The drawable to be used as the background for the view.| 48 | | custom:imageWidth
custom:imageHeight | The dimensions of the image in which the layout coordinates of the children are expressed. | 49 | 50 | In addition, you can use the following optional attributes: 51 | 52 | | Attribute | Description | 53 | |------------------------|------------------------------------| 54 | | custom:fit | Determines how the background image is drawn. Accepted values are vertical, horizontal, both and auto (the default). Check the "Fit attribute" sample in the demo application to see these different modes in action.| 55 | 56 | 57 | ### Adding children 58 | 59 | You can add child views to your ImageLayout just like you would to any other ViewGroup. But instead of using the android:layout_width and android:layout_height attributes to control the layout of children, you should use the following: 60 | 61 | |Attribute |Description | 62 | |--------------------------|-------------| 63 | | custom:layout_width
custom:layout_height | Similar to android:layout_width/height, but expressed in image coordinates | 64 | |custom:layout_maxWidth
custom:layout_maxHeight| Similar to android:layout_maxWidth/maxHeight, but expressed in image coordinates. | 65 | | custom:layout_centerX
custom:layout_centerY|Center of the child view, in image coordinates.| 66 | |custom:layout_left
custom:layout_top
custom:layout_right
custom:layout_bottom|Bounds of the child view, in image coordinates.| 67 | 68 | Note that depending of your application you will use a different combination of these attributes. You might for example specify a value for custom:right in order to align the right side of your view with a given feature of the image, and custom:centerY to align the same view vertically with another feature. 69 | 70 | Also note that the size-related attributes such as custom:layout_width are not mandatory. If you don't specify any of them for a given dimension, the view is measured in the traditional "wrap content" fashion. 71 | 72 | 73 | ### View size adjustment 74 | 75 | You can have your ImageLayout fill its parent by specifying match_parent in both its android:layout_width and android:layout_height attributes. But, since the aspect ratio of the image will typically differ from the aspect of ratio of the parent view, this will result in a waste of screen real state in the form of blank margins around the image. 76 | 77 | To prevent this, simply use wrap_content in either android:layout_width or android:layout_height. This will cause the ImageLayout to adopt a size which matches the aspect ratio of its image. 78 | 79 | Please note that the result of using wrap_content for *both* android:layout_width and android:layout_height is unspecified. 80 | 81 | Who's using it 82 | -------------- 83 | 84 | *Does your app use ImageLayout? If you want to be featured on this list drop me a line.* 85 | 86 | Developed By 87 | -------------------- 88 | 89 | Manuel Peinado Gallego - 90 | 91 | 92 | Follow me on Twitter 94 | 95 | 96 | Follow me on Twitter 98 | 99 | 100 | Follow me on Twitter 102 | 103 | License 104 | ------- 105 | 106 | Copyright 2013 Manuel Peinado 107 | 108 | Licensed under the Apache License, Version 2.0 (the "License"); 109 | you may not use this file except in compliance with the License. 110 | You may obtain a copy of the License at 111 | 112 | http://www.apache.org/licenses/LICENSE-2.0 113 | 114 | Unless required by applicable law or agreed to in writing, software 115 | distributed under the License is distributed on an "AS IS" BASIS, 116 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 117 | See the License for the specific language governing permissions and 118 | limitations under the License. 119 | 120 | [1]: https://raw.github.com/ManuelPeinado/ImageLayout/master/art/readme_pic.png 121 | [2]: https://github.com/ManuelPeinado/ImageLayout/tree/master/sample 122 | -------------------------------------------------------------------------------- /art/boroughs-framed-all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/boroughs-framed-all.png -------------------------------------------------------------------------------- /art/boroughs-framed-galaxy_mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/boroughs-framed-galaxy_mini.png -------------------------------------------------------------------------------- /art/boroughs-framed-galaxy_nexus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/boroughs-framed-galaxy_nexus.png -------------------------------------------------------------------------------- /art/boroughs-framed-nexus7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/boroughs-framed-nexus7.png -------------------------------------------------------------------------------- /art/boroughs-framed-nexus_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/boroughs-framed-nexus_s.png -------------------------------------------------------------------------------- /art/boroughs-framed_xoom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/boroughs-framed_xoom.png -------------------------------------------------------------------------------- /art/hi_res_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/hi_res_icon.png -------------------------------------------------------------------------------- /art/readme_pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/readme_pic.png -------------------------------------------------------------------------------- /art/snapshot0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/snapshot0.png -------------------------------------------------------------------------------- /art/snapshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/art/snapshot1.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:0.9.+' 8 | } 9 | } 10 | 11 | def isReleaseBuild() { 12 | return version.contains("SNAPSHOT") == false 13 | } 14 | 15 | allprojects { 16 | version = VERSION_NAME 17 | group = GROUP 18 | 19 | repositories { 20 | mavenCentral() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_NAME=1.1.0 2 | VERSION_CODE=110 3 | GROUP=com.github.manuelpeinado.imagelayout 4 | 5 | POM_DESCRIPTION=https://github.com/ManuelPeinado/ImageLayout 6 | POM_URL=https://github.com/ManuelPeinado/ImageLayout 7 | POM_SCM_URL=https://github.com/ManuelPeinado/ImageLayout 8 | POM_SCM_CONNECTION=scm:git@github.com:ManuelPeinado/ImageLayout.git 9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:ManuelPeinado/ImageLayout.git 10 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 11 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 12 | POM_LICENCE_DIST=repo 13 | POM_DEVELOPER_ID=manuelpeinado 14 | POM_DEVELOPER_NAME=Manuel Peinado 15 | 16 | ANDROID_BUILD_TOOLS_VERSION=19 17 | ANDROID_COMPILE_SDK_VERSION=19 18 | ANDROID_TARGET_SDK_VERSION=19 19 | ANDROID_MIN_SDK=4 -------------------------------------------------------------------------------- /library/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android-library' 2 | 3 | 4 | android { 5 | compileSdkVersion Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION) 6 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 7 | 8 | defaultConfig { 9 | minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK) 10 | targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION) 11 | } 12 | 13 | sourceSets { 14 | main { 15 | manifest.srcFile 'AndroidManifest.xml' 16 | java.srcDirs = ['src'] 17 | res.srcDirs = ['res'] 18 | } 19 | } 20 | 21 | lintOptions { 22 | abortOnError false 23 | } 24 | } 25 | 26 | apply from: '../maven_push.gradle' 27 | 28 | 29 | -------------------------------------------------------------------------------- /library/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=ImageLayout 2 | POM_ARTIFACT_ID=imagelayout 3 | POM_PACKAGING=aar 4 | -------------------------------------------------------------------------------- /library/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-18 15 | android.library=true 16 | -------------------------------------------------------------------------------- /library/res/values/il__attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 25 | 31 | 32 | 38 | 39 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /library/src/com/manuelpeinado/imagelayout/ImageFitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Manuel Peinado 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.manuelpeinado.imagelayout; 17 | 18 | import android.graphics.Bitmap; 19 | import android.graphics.Rect; 20 | import android.view.Gravity; 21 | 22 | class ImageFitter { 23 | private int gravity; 24 | private int fitMode; 25 | 26 | ImageFitter(int mode, int gravity) { 27 | this.fitMode = mode; 28 | this.gravity = gravity; 29 | } 30 | 31 | Rect fit(Bitmap bmp, int viewWidth, int viewHeight) { 32 | switch (fitMode) { 33 | case ImageLayout.FIT_VERTICAL: 34 | return fitVertical(bmp, viewWidth, viewHeight); 35 | case ImageLayout.FIT_HORIZONTAL: 36 | return fitHorizontal(bmp, viewWidth, viewHeight); 37 | case ImageLayout.FIT_BOTH: 38 | return fitBoth(bmp, viewWidth, viewHeight); 39 | default: 40 | return fitAuto(bmp, viewWidth, viewHeight); 41 | } 42 | } 43 | 44 | private Rect fitHorizontal(Bitmap bmp, int w, int h) { 45 | float bitmapAspectRatio = computeBitmapAspectRatio(bmp); 46 | return fitHorizontal(w, h, bitmapAspectRatio); 47 | } 48 | 49 | private Rect fitVertical(Bitmap bmp, int w, int h) { 50 | float bitmapAspectRatio = computeBitmapAspectRatio(bmp); 51 | return fitVertical(w, h, bitmapAspectRatio); 52 | } 53 | 54 | private Rect fitBoth(Bitmap bmp, int w, int h) { 55 | float bitmapAspectRatio = computeBitmapAspectRatio(bmp); 56 | float viewAspectRatio = w / (float) h; 57 | if (bitmapAspectRatio < viewAspectRatio) { 58 | return fitHorizontal(w, h, bitmapAspectRatio); 59 | } 60 | return fitVertical(w, h, bitmapAspectRatio); 61 | } 62 | 63 | private Rect fitAuto(Bitmap bmp, int w, int h) { 64 | float bitmapAspectRatio = computeBitmapAspectRatio(bmp); 65 | float viewAspectRatio = w / (float) h; 66 | if (bitmapAspectRatio > viewAspectRatio) { 67 | return fitHorizontal(w, h, bitmapAspectRatio); 68 | } 69 | return fitVertical(w, h, bitmapAspectRatio); 70 | } 71 | 72 | private Rect fitHorizontal(int w, int h, float bitmapAspectRatio) { 73 | int destWidth = w; 74 | int destHeight = (int) (destWidth / bitmapAspectRatio); 75 | int vGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK; 76 | int top = 0; 77 | if (vGravity == Gravity.CENTER_VERTICAL) { 78 | top = h / 2 - destHeight / 2; 79 | } 80 | else if (vGravity == Gravity.BOTTOM) { 81 | top = h - destHeight; 82 | } 83 | return new Rect(0, top, destWidth, top + destHeight); 84 | } 85 | 86 | private Rect fitVertical(int w, int h, float bitmapAspectRatio) { 87 | int destHeight = h; 88 | int destWidth = (int) (destHeight * bitmapAspectRatio); 89 | int hGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; 90 | int left = 0; 91 | if (hGravity == Gravity.CENTER_HORIZONTAL) { 92 | left = w / 2 - destWidth / 2; 93 | } 94 | else if (hGravity == Gravity.RIGHT) { 95 | left = w - destWidth; 96 | } 97 | return new Rect(left, 0, left + destWidth, destHeight); 98 | } 99 | 100 | private static float computeBitmapAspectRatio(Bitmap bmp) { 101 | return bmp.getWidth() / (float) bmp.getHeight(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /library/src/com/manuelpeinado/imagelayout/ImageLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Manuel Peinado 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.manuelpeinado.imagelayout; 17 | 18 | import android.content.Context; 19 | import android.content.res.TypedArray; 20 | import android.graphics.Bitmap; 21 | import android.graphics.Canvas; 22 | import android.graphics.Rect; 23 | import android.graphics.drawable.BitmapDrawable; 24 | import android.graphics.drawable.Drawable; 25 | import android.util.AttributeSet; 26 | import android.view.Gravity; 27 | import android.view.View; 28 | import android.view.ViewGroup; 29 | 30 | /** 31 | * A layout that arranges its children in relation to a background image. The 32 | * layout of each child is specified in image coordinates (pixels), and the 33 | * conversion to screen coordinates is performed automatically. 34 | *

The background image is adjusted so that it fills the available space. The exact 35 | * details of this adjustment are controlled by the custom:fit and android:gravity 36 | * attributes 37 | *

For some applications this might be a useful replacement for the now 38 | * deprecated AbsoluteLayout. 39 | */ 40 | public class ImageLayout extends ViewGroup { 41 | 42 | /** 43 | * The image is made to fill the available vertical space, and may be cropped 44 | * horizontally if there is not enough space. 45 | *

If there is too much horizontal space it is left blank. 46 | *

The vertical position of the image is controlled by the android:gravity attribute 47 | */ 48 | public static final int FIT_VERTICAL = 0; 49 | /** 50 | * The image is made to fill the available horizontal space, and may be cropped 51 | * vertically if there is not enough space. 52 | *

If there is too much vertical space it is left blank. 53 | *

The vertical position of the image is controlled by the android:gravity attribute 54 | */ 55 | public static final int FIT_HORIZONTAL = 1; 56 | 57 | /** 58 | * The image fills the available space both vertically and horizontally. 59 | *

If the aspect ratio of the image does not match exactly the aspect ratio 60 | * of the available space, the image is cropped either vertically or horizontally, 61 | * depending on which provides the best fit 62 | */ 63 | public static final int FIT_BOTH = 2; 64 | 65 | /** 66 | * The image is made to fill the available space vertically in portrait mode 67 | * and horizontally in landscape. 68 | *

This is the default mode. 69 | *

Note that the library does not determine the orientation based on the 70 | * actual device orientation, but on the relative aspect ratios of the image 71 | * and the view. 72 | */ 73 | public static final int FIT_AUTO = 3; 74 | 75 | /** 76 | * The fit mode that will be used in case the user does not specify one 77 | */ 78 | public static final int DEFAULT_FIT_MODE = FIT_AUTO; 79 | 80 | private Bitmap bitmap; 81 | private Rect bitmapDestRect; 82 | private int imageWidth; 83 | private int imageHeight; 84 | private Rect bitmapSrcRect; 85 | private ImageFitter fitter; 86 | private int fitMode = DEFAULT_FIT_MODE; 87 | private int gravity = -1; 88 | 89 | public ImageLayout(Context context, AttributeSet attrs) { 90 | super(context, attrs); 91 | setWillNotDraw(false); 92 | parseAttributes(attrs); 93 | } 94 | 95 | private void parseAttributes(AttributeSet attrs) { 96 | if (attrs == null) { 97 | return; 98 | } 99 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ImageLayout); 100 | Drawable drawable = a.getDrawable(R.styleable.ImageLayout_image); 101 | if (drawable == null) { 102 | throw new RuntimeException("Invalid drawable resource in layout description file"); 103 | } 104 | if (!(drawable instanceof BitmapDrawable)) { 105 | throw new RuntimeException("Drawable resource in layout description file must be of type \"BitmapDrawable\""); 106 | } 107 | 108 | bitmap = extractBitmapFromDrawable(drawable); 109 | bitmapSrcRect = bitmapRect(bitmap); 110 | 111 | imageWidth = a.getInteger(R.styleable.ImageLayout_imageWidth, -1); 112 | imageHeight = a.getInteger(R.styleable.ImageLayout_imageHeight, -1); 113 | 114 | int fitMode = a.getInt(R.styleable.ImageLayout_fit, this.fitMode); 115 | setFitMode(fitMode); 116 | 117 | int gravity = a.getInt(R.styleable.ImageLayout_android_gravity, this.gravity); 118 | setGravity(gravity); 119 | a.recycle(); 120 | } 121 | 122 | /** 123 | * Determines how the background image is drawn 124 | * @param newValue Accepted values are {@link ImageLayout#FIT_BOTH}, {@link ImageLayout#FIT_AUTO}, 125 | * {@link ImageLayout#FIT_VERTICAL} and {@link ImageLayout#FIT_HORIZONTAL} 126 | */ 127 | public void setFitMode(int newValue) { 128 | if (fitter != null && fitMode == newValue) { 129 | return; 130 | } 131 | fitMode = newValue; 132 | rebuildFitter(); 133 | } 134 | 135 | public void setGravity(int newValue) { 136 | if (fitter != null && gravity == newValue) { 137 | return; 138 | } 139 | if ((newValue & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) { 140 | newValue |= Gravity.CENTER_HORIZONTAL; 141 | } 142 | if ((newValue & Gravity.VERTICAL_GRAVITY_MASK) == 0) { 143 | newValue |= Gravity.CENTER_VERTICAL; 144 | } 145 | gravity = newValue; 146 | rebuildFitter(); 147 | } 148 | 149 | public int getFitMode() { 150 | return fitMode; 151 | } 152 | 153 | /** 154 | * Changes the background image and its layout dimensions. 155 | */ 156 | public void setImageResource(int imageResource, int imageWidth, int imageHeight) { 157 | bitmap = extractBitmapFromDrawable(getResources().getDrawable(imageResource)); 158 | bitmapSrcRect = bitmapRect(bitmap); 159 | 160 | this.imageWidth = imageWidth; 161 | this.imageHeight = imageHeight; 162 | 163 | rebuildFitter(); 164 | } 165 | 166 | private static Bitmap extractBitmapFromDrawable(Drawable drawable) { 167 | return ((BitmapDrawable) drawable).getBitmap(); 168 | } 169 | 170 | private static Rect bitmapRect(Bitmap bitmap) { 171 | return new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); 172 | } 173 | 174 | private void rebuildFitter() { 175 | fitter = new ImageFitter(fitMode, gravity); 176 | requestLayout(); 177 | invalidate(); 178 | } 179 | 180 | private int transformWidthFromBitmapToView(int w) { 181 | float widthRatio = bitmapDestRect.width() / (float) imageWidth; 182 | return (int) (w * widthRatio); 183 | } 184 | 185 | private int transformHeightFromBitmapToView(int h) { 186 | float heightRatio = bitmapDestRect.height() / (float) imageHeight; 187 | return (int) (h * heightRatio); 188 | } 189 | 190 | private int transformXFromBitmapToView(int x) { 191 | float widthRatio = bitmapDestRect.width() / (float) imageWidth; 192 | return bitmapDestRect.left + (int) (x * widthRatio); 193 | } 194 | 195 | private int transformYFromBitmapToView(int y) { 196 | float heightRatio = bitmapDestRect.height() / (float) imageHeight; 197 | return bitmapDestRect.top + (int) (y * heightRatio); 198 | } 199 | 200 | @Override 201 | protected void onDraw(Canvas canvas) { 202 | canvas.drawBitmap(bitmap, bitmapSrcRect, bitmapDestRect, null); 203 | super.onDraw(canvas); 204 | } 205 | 206 | @Override 207 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 208 | int N = getChildCount(); 209 | for (int i = 0; i < N; ++i) { 210 | View child = getChildAt(i); 211 | LayoutParams layoutParams = (LayoutParams) child.getLayoutParams(); 212 | child.layout(layoutParams.transformedRect.left, layoutParams.transformedRect.top, layoutParams.transformedRect.right, layoutParams.transformedRect.bottom); 213 | } 214 | } 215 | 216 | @Override 217 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 218 | int widthMode = MeasureSpec.getMode(widthMeasureSpec); 219 | int heightMode = MeasureSpec.getMode(heightMeasureSpec); 220 | int widthSpec = MeasureSpec.getSize(widthMeasureSpec); 221 | int width = widthSpec; 222 | int heightSpec = MeasureSpec.getSize(heightMeasureSpec); 223 | int height = heightSpec; 224 | boolean isExactWidth = widthMode == MeasureSpec.EXACTLY; 225 | boolean isExactHeight = heightMode == MeasureSpec.EXACTLY; 226 | float bitmapAspectRatio = (bitmap.getWidth() + getPaddingLeft() + getPaddingRight()) 227 | / ((float)bitmap.getHeight() + getPaddingTop() + getPaddingBottom()); 228 | if (isExactWidth && !isExactHeight) { 229 | height = (int)(width / bitmapAspectRatio); 230 | if (heightMode == MeasureSpec.AT_MOST && height > heightSpec) { 231 | height = heightSpec; 232 | } 233 | } 234 | else if (isExactHeight && !isExactWidth) { 235 | width = (int)(height * bitmapAspectRatio); 236 | if (widthMode == MeasureSpec.AT_MOST && width > widthSpec) { 237 | width = widthSpec; 238 | } 239 | } 240 | setMeasuredDimension(width, height); 241 | 242 | int effectiveWidth = width - getPaddingLeft() - getPaddingRight(); 243 | int effectiveHeight = height - getPaddingTop() - getPaddingBottom(); 244 | bitmapDestRect = fitter.fit(bitmap, effectiveWidth, effectiveHeight); 245 | adjustBitmapRectForPadding(); 246 | 247 | int N = getChildCount(); 248 | for (int i = 0; i < N; ++i) { 249 | View child = getChildAt(i); 250 | measureChild(child); 251 | } 252 | } 253 | 254 | private void measureChild(View child) { 255 | LayoutParams layoutParams = (LayoutParams) child.getLayoutParams(); 256 | checkChildLayoutParams(layoutParams); 257 | int wspec = makeWidthSpec(layoutParams); 258 | int hspec = makeHeightSpec(layoutParams); 259 | child.measure(wspec, hspec); 260 | int left = 0, width = child.getMeasuredWidth(); 261 | if (layoutParams.left != -1) { 262 | left = transformXFromBitmapToView(layoutParams.left); 263 | if (layoutParams.right != -1) { 264 | int right = transformXFromBitmapToView(layoutParams.right); 265 | width = right - left; 266 | } 267 | } else if (layoutParams.right != -1) { 268 | int right = transformXFromBitmapToView(layoutParams.right); 269 | left = right - width; 270 | } else if (layoutParams.centerX != -1) { 271 | int cx = transformXFromBitmapToView(layoutParams.centerX); 272 | left = cx - width / 2; 273 | } 274 | 275 | int top = 0, height = child.getMeasuredHeight(); 276 | if (layoutParams.top != -1) { 277 | top = transformYFromBitmapToView(layoutParams.top); 278 | if (layoutParams.bottom != -1) { 279 | int bottom = transformYFromBitmapToView(layoutParams.bottom); 280 | height = bottom - top; 281 | } 282 | } else if (layoutParams.bottom != -1) { 283 | int bottom = transformYFromBitmapToView(layoutParams.bottom); 284 | top = bottom - height; 285 | } else if (layoutParams.centerY != -1) { 286 | int cy = transformYFromBitmapToView(layoutParams.centerY); 287 | top = cy - height / 2; 288 | } 289 | layoutParams.transformedRect.set(left, top, left + width, top + height); 290 | } 291 | 292 | private void adjustBitmapRectForPadding() { 293 | bitmapDestRect.left += getPaddingLeft(); 294 | bitmapDestRect.right += getPaddingLeft(); 295 | bitmapDestRect.top += getPaddingTop(); 296 | bitmapDestRect.bottom += getPaddingTop(); 297 | } 298 | 299 | private int makeHeightSpec(LayoutParams layoutParams) { 300 | int hspec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); 301 | if (layoutParams.maxHeight != -1) { 302 | int height = transformHeightFromBitmapToView(layoutParams.maxHeight); 303 | hspec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); 304 | } else if (layoutParams.height != LayoutParams.WRAP_CONTENT) { 305 | int height = transformHeightFromBitmapToView(layoutParams.height); 306 | hspec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); 307 | } 308 | return hspec; 309 | } 310 | 311 | private int makeWidthSpec(LayoutParams layoutParams) { 312 | int wspec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); 313 | if (layoutParams.maxWidth != -1) { 314 | int maxWidth = transformWidthFromBitmapToView(layoutParams.maxWidth); 315 | wspec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST); 316 | } else if (layoutParams.width != LayoutParams.WRAP_CONTENT) { 317 | int width = transformWidthFromBitmapToView(layoutParams.width); 318 | wspec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); 319 | } 320 | return wspec; 321 | } 322 | 323 | private void checkChildLayoutParams(LayoutParams layoutParams) { 324 | } 325 | 326 | public static class LayoutParams extends ViewGroup.LayoutParams { 327 | // In image coords 328 | public int maxWidth = -1, maxHeight = -1; 329 | public int left = -1, top = -1, right = -1, bottom = -1; 330 | public int centerX = -1, centerY = -1; 331 | // In view coords 332 | Rect transformedRect = new Rect(); 333 | 334 | public LayoutParams() { 335 | this(null, null); 336 | } 337 | 338 | public LayoutParams(Context c, AttributeSet attrs) { 339 | // We don't call super(c, attrs) to prevent the layout_width and 340 | // layout_height 341 | // attributes from being mandatory 342 | super(WRAP_CONTENT, WRAP_CONTENT); 343 | 344 | if (c == null || attrs == null) { 345 | return; 346 | } 347 | 348 | TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.ImageLayout_Layout); 349 | 350 | int N = a.getIndexCount(); 351 | for (int i = 0; i < N; i++) { 352 | int attr = a.getIndex(i); 353 | switch (attr) { 354 | case R.styleable.ImageLayout_Layout_layout_left: 355 | left = a.getInt(attr, -1); 356 | break; 357 | case R.styleable.ImageLayout_Layout_layout_top: 358 | top = a.getInt(attr, -1); 359 | break; 360 | case R.styleable.ImageLayout_Layout_layout_right: 361 | right = a.getInt(attr, -1); 362 | break; 363 | case R.styleable.ImageLayout_Layout_layout_bottom: 364 | bottom = a.getInt(attr, -1); 365 | break; 366 | case R.styleable.ImageLayout_Layout_layout_centerX: 367 | centerX = a.getInt(attr, -1); 368 | break; 369 | case R.styleable.ImageLayout_Layout_layout_centerY: 370 | centerY = a.getInt(attr, -1); 371 | break; 372 | case R.styleable.ImageLayout_Layout_layout_width: 373 | width = a.getInt(attr, -1); 374 | break; 375 | case R.styleable.ImageLayout_Layout_layout_maxWidth: 376 | maxWidth = a.getInt(attr, -1); 377 | break; 378 | case R.styleable.ImageLayout_Layout_layout_height: 379 | height = a.getInt(attr, -1); 380 | break; 381 | case R.styleable.ImageLayout_Layout_layout_maxHeight: 382 | maxHeight = a.getInt(attr, -1); 383 | break; 384 | } 385 | } 386 | a.recycle(); 387 | } 388 | 389 | LayoutParams(ViewGroup.LayoutParams source) { 390 | super(source); 391 | } 392 | } 393 | 394 | @Override 395 | public LayoutParams generateLayoutParams(AttributeSet attrs) { 396 | return new LayoutParams(getContext(), attrs); 397 | } 398 | 399 | @Override 400 | protected ViewGroup.LayoutParams generateDefaultLayoutParams() { 401 | return new LayoutParams(); 402 | } 403 | 404 | @Override 405 | protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { 406 | return p instanceof LayoutParams; 407 | } 408 | 409 | @Override 410 | protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { 411 | return new LayoutParams(p); 412 | } 413 | } -------------------------------------------------------------------------------- /maven_push.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven' 2 | apply plugin: 'signing' 3 | 4 | def sonatypeRepositoryUrl 5 | if (isReleaseBuild()) { 6 | println 'RELEASE BUILD' 7 | sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 8 | } else { 9 | println 'DEBUG BUILD' 10 | sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/" 11 | } 12 | 13 | afterEvaluate { project -> 14 | uploadArchives { 15 | repositories { 16 | mavenDeployer { 17 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 18 | 19 | pom.artifactId = POM_ARTIFACT_ID 20 | 21 | repository(url: sonatypeRepositoryUrl) { 22 | authentication(userName: nexusUsername, password: nexusPassword) 23 | } 24 | 25 | pom.project { 26 | name POM_NAME 27 | packaging POM_PACKAGING 28 | description POM_DESCRIPTION 29 | url POM_URL 30 | 31 | scm { 32 | url POM_SCM_URL 33 | connection POM_SCM_CONNECTION 34 | developerConnection POM_SCM_DEV_CONNECTION 35 | } 36 | 37 | licenses { 38 | license { 39 | name POM_LICENCE_NAME 40 | url POM_LICENCE_URL 41 | distribution POM_LICENCE_DIST 42 | } 43 | } 44 | 45 | developers { 46 | developer { 47 | id POM_DEVELOPER_ID 48 | name POM_DEVELOPER_NAME 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } 55 | 56 | signing { 57 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } 58 | sign configurations.archives 59 | } 60 | 61 | task androidJavadocs(type: Javadoc) { 62 | source = android.sourceSets.main.allJava 63 | } 64 | 65 | task androidJavadocsJar(type: Jar) { 66 | classifier = 'javadoc' 67 | //basename = artifact_id 68 | from androidJavadocs.destinationDir 69 | } 70 | 71 | task androidSourcesJar(type: Jar) { 72 | classifier = 'sources' 73 | //basename = artifact_id 74 | from android.sourceSets.main.allSource 75 | } 76 | 77 | artifacts { 78 | //archives packageReleaseJar 79 | archives androidSourcesJar 80 | archives androidJavadocsJar 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /sample/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 27 | 28 | 31 | 32 | 35 | 36 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | dependencies { 4 | compile project(':library') 5 | } 6 | 7 | android { 8 | compileSdkVersion Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION) 9 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 10 | 11 | defaultConfig { 12 | minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK) 13 | targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION) 14 | versionName project.VERSION_NAME 15 | versionCode Integer.parseInt(project.VERSION_CODE) 16 | } 17 | 18 | signingConfigs { release } 19 | 20 | buildTypes { 21 | release { 22 | signingConfig signingConfigs.release 23 | } 24 | } 25 | 26 | sourceSets { 27 | main { 28 | manifest.srcFile 'AndroidManifest.xml' 29 | java.srcDirs = ['src'] 30 | res.srcDirs = ['res'] 31 | } 32 | } 33 | 34 | lintOptions { 35 | abortOnError false 36 | } 37 | } 38 | 39 | 40 | File propFile = file('signing.properties'); 41 | if (propFile.exists()) { 42 | def Properties props = new Properties() 43 | props.load(new FileInputStream(propFile)) 44 | 45 | if (props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') && 46 | props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) { 47 | android.signingConfigs.release.storeFile = file(props['STORE_FILE']) 48 | android.signingConfigs.release.storePassword = props['STORE_PASSWORD'] 49 | android.signingConfigs.release.keyAlias = props['KEY_ALIAS'] 50 | android.signingConfigs.release.keyPassword = props['KEY_PASSWORD'] 51 | } else { 52 | android.buildTypes.release.signingConfig = null 53 | } 54 | } else { 55 | android.buildTypes.release.signingConfig = null 56 | } 57 | -------------------------------------------------------------------------------- /sample/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-17 15 | android.library=false 16 | android.library.reference.1=../library 17 | -------------------------------------------------------------------------------- /sample/res/drawable-hdpi/boroughs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-hdpi/boroughs.png -------------------------------------------------------------------------------- /sample/res/drawable-hdpi/curiosity.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-hdpi/curiosity.jpg -------------------------------------------------------------------------------- /sample/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/res/drawable-hdpi/manhattan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-hdpi/manhattan.jpg -------------------------------------------------------------------------------- /sample/res/drawable-mdpi/boroughs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-mdpi/boroughs.png -------------------------------------------------------------------------------- /sample/res/drawable-mdpi/curiosity.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-mdpi/curiosity.jpg -------------------------------------------------------------------------------- /sample/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/res/drawable-mdpi/manhattan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-mdpi/manhattan.jpg -------------------------------------------------------------------------------- /sample/res/drawable-xhdpi/boroughs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-xhdpi/boroughs.png -------------------------------------------------------------------------------- /sample/res/drawable-xhdpi/curiosity.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-xhdpi/curiosity.jpg -------------------------------------------------------------------------------- /sample/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/res/drawable-xhdpi/manhattan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-xhdpi/manhattan.jpg -------------------------------------------------------------------------------- /sample/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManuelPeinado/ImageLayout/6be0b5dc361ca1e1039cd8c40ad63721b7a1a154/sample/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/res/layout/activity_add_children_programmatically.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | -------------------------------------------------------------------------------- /sample/res/layout/activity_basic_usage.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 19 | 20 |