diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d342ae5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.gradle +.idea +.cxx +.externalNativeBuild +build +captures + +._* +*.iml +.DS_Store +local.properties \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..011d173 --- /dev/null +++ b/README.md @@ -0,0 +1,568 @@ +# Shape 框架 + +* 项目地址:[Github](https://github.com/getActivity/ShapeView)、[码云](https://gitee.com/getActivity/ShapeView) + +* 点击此处 [下载 Demo](ShapeView.apk) 进行演示或者测试 + +#### 集成步骤 + +* 在项目根目录下的 `build.gradle` 文件中加入 + +```groovy +buildscript { + repositories { + maven { url 'https://jitpack.io' } + } +} +allprojects { + repositories { + maven { url 'https://jitpack.io' } + } +} +``` + +* 在项目 app 模块下的 `build.gradle` 文件中加入 + +```groovy +android { + // 支持 JDK 1.8 + compileOptions { + targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + // 权限请求框架:https://github.com/getActivity/ShapeView + implementation 'com.github.getActivity:ShapeView:2.0' +} +``` + +#### AndroidX + +* 如果项目是基于 **AndroidX** 包,请在项目 `gradle.properties` 文件中加入 + +```groovy +# 表示将第三方库迁移到 AndroidX +android.enableJetifier = true +``` + +* 如果项目是基于 **Support** 包则不需要加入此配置 + +#### 框架文档 + +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +#### 使用案例 + +![](picture/1.jpg) + +```xml + + + + + + + +``` + +![](picture/2.jpg) + +```xml + + + + + + + + + + + +``` + +![](picture/3.jpg) + +```xml + + + + + + + + + +``` + +![](picture/4.jpg) + +```xml + + + + + + + + + + + +``` + +![](picture/5.jpg) + +```xml + + + +``` + +* 目前支持的控件有: + + * View:ShapeView、ShapeTextView、ShapeButton、ShapeImageView、ShapeRadioButton、ShapeCheckBox、ShapeEditText + + * Layout:ShapeLinearLayout、ShapeFrameLayout、ShapeRelativeLayout、ShapeConstraintLayout、ShapeRecyclerView + +#### 框架亮点 + +* 更加便捷:无需新增 Xml 文件,直接定义控件属性即可 + +* 即时生效:在布局中可实时预览效果,即见所得 + +* 无学习成本:控件属性和原生 Shape 命名保持一致,无需额外学习 + +* 覆盖范围广:几乎涵盖所有常见的 View 控件,并且控件名称无任何记忆成本 + +#### 作者的其他开源项目 + +* 安卓技术中台:[AndroidProject](https://github.com/getActivity/AndroidProject) + +* 权限框架:[XXPermissions](https://github.com/getActivity/XXPermissions) + +* 吐司框架:[ToastUtils](https://github.com/getActivity/ToastUtils) + +* 网络框架:[EasyHttp](https://github.com/getActivity/EasyHttp) + +* 标题栏框架:[TitleBar](https://github.com/getActivity/TitleBar) + +* 国际化框架:[MultiLanguages](https://github.com/getActivity/MultiLanguages) + +* 悬浮窗框架:[XToast](https://github.com/getActivity/XToast) + +* Gson 解析容错:[GsonFactory](https://github.com/getActivity/GsonFactory) + +* 日志查看框架:[Logcat](https://github.com/getActivity/Logcat) + +#### 微信公众号:Android轮子哥 + +![](https://raw.githubusercontent.com/getActivity/Donate/master/picture/official_ccount.png) + +#### Android 技术分享 QQ 群:78797078 + +#### 如果您觉得我的开源库帮你节省了大量的开发时间,请扫描下方的二维码随意打赏,要是能打赏个 10.24 :monkey_face:就太:thumbsup:了。您的支持将鼓励我继续创作:octocat: + +![](https://raw.githubusercontent.com/getActivity/Donate/master/picture/pay_ali.png) ![](https://raw.githubusercontent.com/getActivity/Donate/master/picture/pay_wechat.png) + +#### [点击查看捐赠列表](https://github.com/getActivity/Donate) + +## License + +```text +Copyright 2021 Huang JinQun + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` \ No newline at end of file diff --git a/ShapeView.apk b/ShapeView.apk new file mode 100644 index 0000000..7c88fad Binary files /dev/null and b/ShapeView.apk differ diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..1378b1e --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,36 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + + defaultConfig { + applicationId "com.hjq.shape.demo" + minSdkVersion 16 + targetSdkVersion 28 + versionCode 20 + versionName "2.0" + + // 支持 Java JDK 8 + compileOptions { + targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation project(':library') + + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support:design:28.0.0' + + // 标题栏框架:https://github.com/getActivity/TitleBar + implementation 'com.github.getActivity:TitleBar:8.6' +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..325e97d --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in D:\SDK\Studio\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..beb3d73 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/hjq/shape/demo/MainActivity.java b/app/src/main/java/com/hjq/shape/demo/MainActivity.java new file mode 100644 index 0000000..9f84750 --- /dev/null +++ b/app/src/main/java/com/hjq/shape/demo/MainActivity.java @@ -0,0 +1,13 @@ +package com.hjq.shape.demo; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..f077a60 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,440 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..9a078e3 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..3af2608 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9bec2e6 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml new file mode 100644 index 0000000..2f9ebe3 --- /dev/null +++ b/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..60a81e0 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #000000 + #000000 + #FF0033 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..a185b86 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + ShapeView + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f46b18a --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..f6ac2c3 --- /dev/null +++ b/build.gradle @@ -0,0 +1,33 @@ +buildscript { + repositories { + // 阿里云云效仓库:https://maven.aliyun.com/mvn/guide + maven { url 'https://maven.aliyun.com/repository/jcenter' } + maven { url 'https://maven.aliyun.com/repository/google' } + // 华为开源镜像:https://mirrors.huaweicloud.com/ + maven { url 'https://repo.huaweicloud.com/repository/maven/' } + // JitPack 远程仓库:https://jitpack.io + maven { url 'https://jitpack.io' } + mavenCentral() + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:4.1.2' + } +} + +allprojects { + repositories { + maven { url 'https://maven.aliyun.com/repository/jcenter' } + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://repo.huaweicloud.com/repository/maven/' } + maven { url 'https://jitpack.io' } + mavenCentral() + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..89196d1 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e9329ac --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +zipStoreBase = GRADLE_USER_HOME +zipStorePath = wrapper/dists +distributionBase = GRADLE_USER_HOME +distributionPath = wrapper/dists +distributionUrl = https\://services.gradle.org/distributions/gradle-6.5-all.zip \ No newline at end of file diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/library/build.gradle b/library/build.gradle new file mode 100644 index 0000000..01e2298 --- /dev/null +++ b/library/build.gradle @@ -0,0 +1,58 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 26 + + defaultConfig { + minSdkVersion 16 + versionCode 20 + versionName "2.0" + } + + // 支持 Java JDK 8 + compileOptions { + targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 + } + + android.libraryVariants.all { variant -> + // aar 输出文件名配置 + variant.outputs.all { output -> + outputFileName = "${rootProject.name}-${android.defaultConfig.versionName}.aar" + } + } +} + +dependencies { + implementation 'com.android.support:appcompat-v7:26.0.0' + implementation 'com.android.support:design:26.0.0' + // noinspection GradleDependency + implementation 'com.android.support.constraint:constraint-layout:1.0.2' +} + +// 防止编码问题 +tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') + options.addStringOption('encoding', 'UTF-8') + options.addStringOption('charSet', 'UTF-8') +} + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} + +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives javadocJar + archives sourcesJar +} \ No newline at end of file diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro new file mode 100644 index 0000000..325e97d --- /dev/null +++ b/library/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in D:\SDK\Studio\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4a34b81 --- /dev/null +++ b/library/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/IShapeDrawable.java b/library/src/main/java/com/hjq/shape/IShapeDrawable.java new file mode 100644 index 0000000..4408b68 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/IShapeDrawable.java @@ -0,0 +1,187 @@ +package com.hjq.shape; + +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; +import android.view.View; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : Shape 接口规范 + */ +public interface IShapeDrawable { + + int DEFAULT_SHAPE = GradientDrawable.RECTANGLE; + int DEFAULT_SHAPE_WIDTH = -1; + int DEFAULT_SHAPE_HEIGHT = -1; + int DEFAULT_SHAPE_SOLID_COLOR = Color.TRANSPARENT; + int DEFAULT_SHAPE_RADIUS = 0; + int DEFAULT_SHAPE_START_COLOR = Color.TRANSPARENT; + int DEFAULT_SHAPE_CENTER_COLOR = Color.TRANSPARENT; + int DEFAULT_SHAPE_END_COLOR = Color.TRANSPARENT; + boolean DEFAULT_SHAPE_USE_LEVEL = false; + int DEFAULT_SHAPE_GRADIENT_TYPE = GradientDrawable.LINEAR_GRADIENT; + int DEFAULT_SHAPE_ANGLE = 0; + float DEFAULT_SHAPE_CENTER_X = 0.5f; + float DEFAULT_SHAPE_CENTER_Y = 0.5f; + int DEFAULT_SHAPE_STROKE_COLOR = Color.TRANSPARENT; + int DEFAULT_SHAPE_STROKE_WIDTH = 0; + int DEFAULT_SHAPE_DASH_WIDTH = 0; + int DEFAULT_SHAPE_DASH_GAP = 0; + + V setShape(int shape); + + int getShape(); + + V setShapeWidth(int width); + + int getShapeWidth(); + + V setShapeHeight(int height); + + int getShapeHeight(); + + V setSolidColor(int color); + + int getSolidColor(); + + default V setRadius(int radius) { + setTopLeftRadius(radius); + setTopRightRadius(radius); + setBottomLeftRadius(radius); + return setBottomRightRadius(radius); + } + + V setTopLeftRadius(int radius); + + int getTopLeftRadius(); + + V setTopRightRadius(int radius); + + int getTopRightRadius(); + + V setBottomLeftRadius(int radius); + + int getBottomLeftRadius(); + + V setBottomRightRadius(int radius); + + int getBottomRightRadius(); + + V setStartColor(int color); + + int getStartColor(); + + V setCenterColor(int color); + + int getCenterColor(); + + V setEndColor(int color); + + int getEndColor(); + + V setUseLevel(boolean useLevel); + + boolean isUseLevel(); + + V setAngle(int angle); + + int getAngle(); + + V setGradientType(int type); + + int getGradientType(); + + V setCenterX(float x); + + float getCenterX(); + + V setCenterY(float y); + + float getCenterY(); + + V setGradientRadius(int radius); + + int getGradientRadius(); + + V setStrokeColor(int color); + + int getStrokeColor(); + + V setStrokeWidth(int width); + + int getStrokeWidth(); + + V setDashWidth(int width); + + int getDashWidth(); + + V setDashGap(int gap); + + int getDashGap(); + + default Drawable build() { + GradientDrawable drawable = new GradientDrawable(); + drawable.setShape(getShape()); + drawable.setSize(getShapeWidth(), getShapeHeight()); + drawable.setCornerRadii(new float[]{getTopLeftRadius(), getTopLeftRadius(), getTopRightRadius(), getTopRightRadius(), + getBottomRightRadius(), getBottomRightRadius(), getBottomLeftRadius(), getBottomLeftRadius()}); + drawable.setColor(getSolidColor()); + + int startColor = getStartColor(); + int centerColor = getCenterColor(); + int endColor = getEndColor(); + if (startColor != 0 || centerColor != 0 || endColor != 0) { + if (centerColor == 0) { + drawable.setColors(new int[]{startColor, endColor}); + } else { + drawable.setColors(new int[]{startColor, centerColor, endColor}); + } + } + + drawable.setGradientCenter(getCenterX(), getCenterY()); + drawable.setUseLevel(isUseLevel()); + int angle = getAngle(); + angle %= 360; + // angle 必须为 45 的整数倍 + if (angle % 45 == 0) { + switch (angle) { + case 0: + drawable.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT); + break; + case 45: + drawable.setOrientation(GradientDrawable.Orientation.BL_TR); + break; + case 90: + drawable.setOrientation(GradientDrawable.Orientation.BOTTOM_TOP); + break; + case 135: + drawable.setOrientation(GradientDrawable.Orientation.BR_TL); + break; + case 180: + drawable.setOrientation(GradientDrawable.Orientation.RIGHT_LEFT); + break; + case 225: + drawable.setOrientation(GradientDrawable.Orientation.TR_BL); + break; + case 270: + drawable.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM); + break; + case 315: + drawable.setOrientation(GradientDrawable.Orientation.TL_BR); + break; + default: + break; + } + } + + drawable.setGradientType(getGradientType()); + drawable.setGradientRadius(getGradientRadius()); + drawable.setStroke(getStrokeWidth(), getStrokeColor(), getDashWidth(), getDashGap()); + return drawable; + } + + void into(); +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/layout/ShapeConstraintLayout.java b/library/src/main/java/com/hjq/shape/layout/ShapeConstraintLayout.java new file mode 100644 index 0000000..cd4ca70 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/layout/ShapeConstraintLayout.java @@ -0,0 +1,323 @@ +package com.hjq.shape.layout; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.View; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 ConstraintLayout + */ +public class ShapeConstraintLayout extends View implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeConstraintLayout(Context context) { + this(context, null); + } + + public ShapeConstraintLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeConstraintLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeConstraintLayout); + mShape = typedArray.getInt(R.styleable.ShapeConstraintLayout_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeConstraintLayout_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeConstraintLayout_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeConstraintLayout_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeConstraintLayout_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeConstraintLayout_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeConstraintLayout_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeConstraintLayout_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeConstraintLayout_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeConstraintLayout_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeConstraintLayout_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeConstraintLayout_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeConstraintLayout_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeConstraintLayout_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeConstraintLayout setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeConstraintLayout setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeConstraintLayout setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeConstraintLayout setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeConstraintLayout setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeConstraintLayout setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeConstraintLayout setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeConstraintLayout setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeConstraintLayout setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeConstraintLayout setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeConstraintLayout setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeConstraintLayout setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeConstraintLayout setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeConstraintLayout setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeConstraintLayout setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeConstraintLayout setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeConstraintLayout setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeConstraintLayout setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeConstraintLayout setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeConstraintLayout setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeConstraintLayout setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/layout/ShapeFrameLayout.java b/library/src/main/java/com/hjq/shape/layout/ShapeFrameLayout.java new file mode 100644 index 0000000..de69319 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/layout/ShapeFrameLayout.java @@ -0,0 +1,323 @@ +package com.hjq.shape.layout; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.View; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 FrameLayout + */ +public class ShapeFrameLayout extends View implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeFrameLayout(Context context) { + this(context, null); + } + + public ShapeFrameLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeFrameLayout); + mShape = typedArray.getInt(R.styleable.ShapeFrameLayout_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeFrameLayout_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeFrameLayout_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeFrameLayout_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeFrameLayout_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeFrameLayout_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeFrameLayout_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeFrameLayout_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeFrameLayout_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeFrameLayout_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeFrameLayout_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeFrameLayout_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeFrameLayout_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeFrameLayout_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeFrameLayout setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeFrameLayout setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeFrameLayout setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeFrameLayout setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeFrameLayout setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeFrameLayout setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeFrameLayout setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeFrameLayout setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeFrameLayout setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeFrameLayout setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeFrameLayout setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeFrameLayout setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeFrameLayout setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeFrameLayout setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeFrameLayout setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeFrameLayout setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeFrameLayout setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeFrameLayout setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeFrameLayout setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeFrameLayout setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeFrameLayout setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/layout/ShapeLinearLayout.java b/library/src/main/java/com/hjq/shape/layout/ShapeLinearLayout.java new file mode 100644 index 0000000..9f3c272 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/layout/ShapeLinearLayout.java @@ -0,0 +1,323 @@ +package com.hjq.shape.layout; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.View; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 LinearLayout + */ +public class ShapeLinearLayout extends View implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeLinearLayout(Context context) { + this(context, null); + } + + public ShapeLinearLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeLinearLayout); + mShape = typedArray.getInt(R.styleable.ShapeLinearLayout_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeLinearLayout_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeLinearLayout_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeLinearLayout_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeLinearLayout_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeLinearLayout_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeLinearLayout_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeLinearLayout_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeLinearLayout_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeLinearLayout_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeLinearLayout_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeLinearLayout_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeLinearLayout_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeLinearLayout_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeLinearLayout setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeLinearLayout setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeLinearLayout setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeLinearLayout setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeLinearLayout setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeLinearLayout setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeLinearLayout setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeLinearLayout setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeLinearLayout setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeLinearLayout setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeLinearLayout setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeLinearLayout setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeLinearLayout setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeLinearLayout setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeLinearLayout setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeLinearLayout setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeLinearLayout setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeLinearLayout setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeLinearLayout setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeLinearLayout setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeLinearLayout setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/layout/ShapeRecyclerView.java b/library/src/main/java/com/hjq/shape/layout/ShapeRecyclerView.java new file mode 100644 index 0000000..686cb1b --- /dev/null +++ b/library/src/main/java/com/hjq/shape/layout/ShapeRecyclerView.java @@ -0,0 +1,323 @@ +package com.hjq.shape.layout; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.View; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 RecyclerView + */ +public class ShapeRecyclerView extends View implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeRecyclerView(Context context) { + this(context, null); + } + + public ShapeRecyclerView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeRecyclerView); + mShape = typedArray.getInt(R.styleable.ShapeRecyclerView_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeRecyclerView_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeRecyclerView_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeRecyclerView_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeRecyclerView_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeRecyclerView_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeRecyclerView_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeRecyclerView_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeRecyclerView_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeRecyclerView_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeRecyclerView_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeRecyclerView_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeRecyclerView_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeRecyclerView_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeRecyclerView setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeRecyclerView setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeRecyclerView setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeRecyclerView setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeRecyclerView setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeRecyclerView setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeRecyclerView setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeRecyclerView setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeRecyclerView setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeRecyclerView setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeRecyclerView setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeRecyclerView setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeRecyclerView setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeRecyclerView setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeRecyclerView setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeRecyclerView setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeRecyclerView setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeRecyclerView setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeRecyclerView setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeRecyclerView setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeRecyclerView setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/layout/ShapeRelativeLayout.java b/library/src/main/java/com/hjq/shape/layout/ShapeRelativeLayout.java new file mode 100644 index 0000000..fda1522 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/layout/ShapeRelativeLayout.java @@ -0,0 +1,323 @@ +package com.hjq.shape.layout; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.View; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 RelativeLayout + */ +public class ShapeRelativeLayout extends View implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeRelativeLayout(Context context) { + this(context, null); + } + + public ShapeRelativeLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeRelativeLayout); + mShape = typedArray.getInt(R.styleable.ShapeRelativeLayout_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeRelativeLayout_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeRelativeLayout_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeRelativeLayout_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeRelativeLayout_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeRelativeLayout_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeRelativeLayout_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeRelativeLayout_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeRelativeLayout_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeRelativeLayout_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeRelativeLayout_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeRelativeLayout_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeRelativeLayout_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeRelativeLayout_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeRelativeLayout setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeRelativeLayout setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeRelativeLayout setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeRelativeLayout setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeRelativeLayout setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeRelativeLayout setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeRelativeLayout setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeRelativeLayout setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeRelativeLayout setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeRelativeLayout setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeRelativeLayout setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeRelativeLayout setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeRelativeLayout setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeRelativeLayout setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeRelativeLayout setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeRelativeLayout setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeRelativeLayout setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeRelativeLayout setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeRelativeLayout setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeRelativeLayout setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeRelativeLayout setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/view/ShapeButton.java b/library/src/main/java/com/hjq/shape/view/ShapeButton.java new file mode 100644 index 0000000..91103a5 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/view/ShapeButton.java @@ -0,0 +1,323 @@ +package com.hjq.shape.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.support.v7.widget.AppCompatButton; +import android.util.AttributeSet; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 Button + */ +public class ShapeButton extends AppCompatButton implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeButton(Context context) { + this(context, null); + } + + public ShapeButton(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeButton(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeButton); + mShape = typedArray.getInt(R.styleable.ShapeButton_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeButton_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeButton_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeButton_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeButton_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeButton_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeButton_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeButton_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeButton_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeButton_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeButton_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeButton_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeButton_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeButton_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeButton setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeButton setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeButton setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeButton setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeButton setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeButton setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeButton setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeButton setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeButton setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeButton setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeButton setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeButton setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeButton setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeButton setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeButton setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeButton setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeButton setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeButton setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeButton setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeButton setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeButton setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/view/ShapeCheckBox.java b/library/src/main/java/com/hjq/shape/view/ShapeCheckBox.java new file mode 100644 index 0000000..1a55ce1 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/view/ShapeCheckBox.java @@ -0,0 +1,323 @@ +package com.hjq.shape.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.support.v7.widget.AppCompatCheckBox; +import android.util.AttributeSet; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 CheckBox + */ +public class ShapeCheckBox extends AppCompatCheckBox implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeCheckBox(Context context) { + this(context, null); + } + + public ShapeCheckBox(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeCheckBox(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeCheckBox); + mShape = typedArray.getInt(R.styleable.ShapeCheckBox_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeCheckBox_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeCheckBox_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeCheckBox_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeCheckBox_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeCheckBox_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeCheckBox_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeCheckBox_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeCheckBox_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeCheckBox_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeCheckBox_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeCheckBox_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeCheckBox_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeCheckBox_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeCheckBox setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeCheckBox setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeCheckBox setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeCheckBox setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeCheckBox setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeCheckBox setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeCheckBox setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeCheckBox setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeCheckBox setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeCheckBox setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeCheckBox setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeCheckBox setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeCheckBox setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeCheckBox setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeCheckBox setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeCheckBox setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeCheckBox setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeCheckBox setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeCheckBox setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeCheckBox setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeCheckBox setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/view/ShapeEditText.java b/library/src/main/java/com/hjq/shape/view/ShapeEditText.java new file mode 100644 index 0000000..8855f33 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/view/ShapeEditText.java @@ -0,0 +1,323 @@ +package com.hjq.shape.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.support.v7.widget.AppCompatEditText; +import android.util.AttributeSet; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 EditText + */ +public class ShapeEditText extends AppCompatEditText implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeEditText(Context context) { + this(context, null); + } + + public ShapeEditText(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeEditText(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeEditText); + mShape = typedArray.getInt(R.styleable.ShapeEditText_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeEditText_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeEditText_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeEditText_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeEditText_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeEditText_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeEditText_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeEditText_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeEditText_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeEditText_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeEditText_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeEditText_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeEditText_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeEditText_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeEditText setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeEditText setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeEditText setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeEditText setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeEditText setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeEditText setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeEditText setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeEditText setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeEditText setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeEditText setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeEditText setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeEditText setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeEditText setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeEditText setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeEditText setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeEditText setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeEditText setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeEditText setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeEditText setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeEditText setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeEditText setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/view/ShapeImageView.java b/library/src/main/java/com/hjq/shape/view/ShapeImageView.java new file mode 100644 index 0000000..fbaa9ac --- /dev/null +++ b/library/src/main/java/com/hjq/shape/view/ShapeImageView.java @@ -0,0 +1,323 @@ +package com.hjq.shape.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.support.v7.widget.AppCompatImageView; +import android.util.AttributeSet; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 ImageView + */ +public class ShapeImageView extends AppCompatImageView implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeImageView(Context context) { + this(context, null); + } + + public ShapeImageView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeImageView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeImageView); + mShape = typedArray.getInt(R.styleable.ShapeImageView_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeImageView_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeImageView_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeImageView_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeImageView_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeImageView_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeImageView_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeImageView_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeImageView_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeImageView_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeImageView_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeImageView_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeImageView_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeImageView_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeImageView setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeImageView setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeImageView setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeImageView setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeImageView setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeImageView setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeImageView setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeImageView setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeImageView setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeImageView setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeImageView setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeImageView setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeImageView setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeImageView setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeImageView setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeImageView setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeImageView setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeImageView setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeImageView setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeImageView setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeImageView setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/view/ShapeRadioButton.java b/library/src/main/java/com/hjq/shape/view/ShapeRadioButton.java new file mode 100644 index 0000000..fb48548 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/view/ShapeRadioButton.java @@ -0,0 +1,323 @@ +package com.hjq.shape.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.support.v7.widget.AppCompatRadioButton; +import android.util.AttributeSet; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 RadioButton + */ +public class ShapeRadioButton extends AppCompatRadioButton implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeRadioButton(Context context) { + this(context, null); + } + + public ShapeRadioButton(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeRadioButton(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeRadioButton); + mShape = typedArray.getInt(R.styleable.ShapeRadioButton_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeRadioButton_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeRadioButton_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeRadioButton_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeRadioButton_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeRadioButton_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeRadioButton_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeRadioButton_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeRadioButton_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeRadioButton_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeRadioButton_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeRadioButton_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeRadioButton_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeRadioButton_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeRadioButton setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeRadioButton setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeRadioButton setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeRadioButton setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeRadioButton setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeRadioButton setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeRadioButton setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeRadioButton setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeRadioButton setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeRadioButton setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeRadioButton setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeRadioButton setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeRadioButton setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeRadioButton setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeRadioButton setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeRadioButton setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeRadioButton setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeRadioButton setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeRadioButton setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeRadioButton setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeRadioButton setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/view/ShapeTextView.java b/library/src/main/java/com/hjq/shape/view/ShapeTextView.java new file mode 100644 index 0000000..23ffd86 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/view/ShapeTextView.java @@ -0,0 +1,323 @@ +package com.hjq.shape.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.support.v7.widget.AppCompatTextView; +import android.util.AttributeSet; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 TextView + */ +public class ShapeTextView extends AppCompatTextView implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeTextView(Context context) { + this(context, null); + } + + public ShapeTextView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeTextView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeTextView); + mShape = typedArray.getInt(R.styleable.ShapeTextView_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeTextView_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeTextView_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeTextView_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeTextView_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeTextView_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeTextView_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeTextView_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeTextView_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeTextView_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeTextView_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeTextView_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeTextView_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeTextView_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeTextView setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeTextView setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeTextView setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeTextView setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeTextView setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeTextView setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeTextView setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeTextView setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeTextView setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeTextView setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeTextView setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeTextView setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeTextView setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeTextView setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeTextView setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeTextView setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeTextView setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeTextView setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeTextView setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeTextView setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeTextView setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/shape/view/ShapeView.java b/library/src/main/java/com/hjq/shape/view/ShapeView.java new file mode 100644 index 0000000..e77c1a7 --- /dev/null +++ b/library/src/main/java/com/hjq/shape/view/ShapeView.java @@ -0,0 +1,323 @@ +package com.hjq.shape.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.View; + +import com.hjq.shape.IShapeDrawable; +import com.hjq.shape.R; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/ShapeView + * time : 2021/07/17 + * desc : 支持直接定义 Shape 背景的 View + */ +public class ShapeView extends View implements IShapeDrawable { + + private int mShape; + private int mShapeWidth; + private int mShapeHeight; + private int mSolidColor; + private int mTopLeftRadius; + private int mTopRightRadius; + private int mBottomLeftRadius; + private int mBottomRightRadius; + + private int mStartColor; + private int mCenterColor; + private int mEndColor; + private boolean mUseLevel; + private int mAngle; + private int mGradientType; + private float mCenterX; + private float mCenterY; + private int mGradientRadius; + + private int mStrokeColor; + private int mStrokeWidth; + private int mDashWidth; + private int mDashGap; + + public ShapeView(Context context) { + this(context, null); + } + + public ShapeView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public ShapeView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeView); + mShape = typedArray.getInt(R.styleable.ShapeView_shape, DEFAULT_SHAPE); + mShapeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_width, DEFAULT_SHAPE_WIDTH); + mShapeHeight = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_height, DEFAULT_SHAPE_HEIGHT); + + mSolidColor = typedArray.getColor(R.styleable.ShapeView_shape_solidColor, DEFAULT_SHAPE_SOLID_COLOR); + int radius = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_radius, DEFAULT_SHAPE_RADIUS); + mTopLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_topLeftRadius, radius); + mTopRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_topRightRadius, radius); + mBottomLeftRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_bottomLeftRadius, radius); + mBottomRightRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_bottomRightRadius, radius); + + mStartColor = typedArray.getColor(R.styleable.ShapeView_shape_startColor, DEFAULT_SHAPE_START_COLOR); + mCenterColor = typedArray.getColor(R.styleable.ShapeView_shape_centerColor, DEFAULT_SHAPE_CENTER_COLOR); + mEndColor = typedArray.getColor(R.styleable.ShapeView_shape_endColor, DEFAULT_SHAPE_END_COLOR); + mUseLevel = typedArray.getBoolean(R.styleable.ShapeView_shape_useLevel, DEFAULT_SHAPE_USE_LEVEL); + mAngle = (int) typedArray.getFloat(R.styleable.ShapeView_shape_angle, DEFAULT_SHAPE_ANGLE); + mGradientType = typedArray.getInt(R.styleable.ShapeView_shape_gradientType, DEFAULT_SHAPE_GRADIENT_TYPE); + mCenterX = typedArray.getFloat(R.styleable.ShapeView_shape_centerX, DEFAULT_SHAPE_CENTER_X); + mCenterY = typedArray.getFloat(R.styleable.ShapeView_shape_centerX, DEFAULT_SHAPE_CENTER_Y); + mGradientRadius = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_gradientRadius, radius); + + mStrokeColor = typedArray.getColor(R.styleable.ShapeView_shape_strokeColor, DEFAULT_SHAPE_STROKE_COLOR); + mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.ShapeView_shape_strokeWidth, DEFAULT_SHAPE_STROKE_WIDTH); + mDashWidth = (int) typedArray.getDimension(R.styleable.ShapeView_shape_dashWidth, DEFAULT_SHAPE_DASH_WIDTH); + mDashGap = (int) typedArray.getDimension(R.styleable.ShapeView_shape_dashGap, DEFAULT_SHAPE_DASH_GAP); + + typedArray.recycle(); + + if (getBackground() == null) { + into(); + } + } + + @Override + public ShapeView setShape(int shape) { + mShape = shape; + return this; + } + + @Override + public int getShape() { + return mShape; + } + + @Override + public ShapeView setShapeWidth(int width) { + mShapeWidth = width; + return this; + } + + @Override + public int getShapeWidth() { + return mShapeWidth; + } + + @Override + public ShapeView setShapeHeight(int height) { + mShapeHeight = height; + return this; + } + + @Override + public int getShapeHeight() { + return mShapeHeight; + } + + @Override + public ShapeView setSolidColor(int color) { + mSolidColor = color; + return this; + } + + @Override + public int getSolidColor() { + return mSolidColor; + } + + @Override + public ShapeView setTopLeftRadius(int radius) { + mTopLeftRadius = radius; + return this; + } + + @Override + public int getTopLeftRadius() { + return mTopLeftRadius; + } + + @Override + public ShapeView setTopRightRadius(int radius) { + mTopRightRadius = radius; + return this; + } + + @Override + public int getTopRightRadius() { + return mTopRightRadius; + } + + @Override + public ShapeView setBottomLeftRadius(int radius) { + mBottomLeftRadius = radius; + return this; + } + + @Override + public int getBottomLeftRadius() { + return mBottomLeftRadius; + } + + @Override + public ShapeView setBottomRightRadius(int radius) { + mBottomRightRadius = radius; + return this; + } + + @Override + public int getBottomRightRadius() { + return mBottomRightRadius; + } + + @Override + public ShapeView setStartColor(int color) { + mStartColor = color; + return this; + } + + @Override + public int getStartColor() { + return mStartColor; + } + + @Override + public ShapeView setCenterColor(int color) { + mCenterColor = color; + return this; + } + + @Override + public int getCenterColor() { + return mCenterColor; + } + + @Override + public ShapeView setEndColor(int color) { + mEndColor = color; + return this; + } + + @Override + public int getEndColor() { + return mEndColor; + } + + @Override + public ShapeView setUseLevel(boolean useLevel) { + mUseLevel = useLevel; + return this; + } + + @Override + public boolean isUseLevel() { + return mUseLevel; + } + + @Override + public ShapeView setAngle(int angle) { + mAngle = angle; + return this; + } + + @Override + public int getAngle() { + return mAngle; + } + + @Override + public ShapeView setGradientType(int type) { + mGradientType = type; + return this; + } + + @Override + public int getGradientType() { + return mGradientType; + } + + @Override + public ShapeView setCenterX(float x) { + mCenterX = x; + return this; + } + + @Override + public float getCenterX() { + return mCenterX; + } + + @Override + public ShapeView setCenterY(float y) { + mCenterY = y; + return this; + } + + @Override + public float getCenterY() { + return mCenterY; + } + + @Override + public ShapeView setGradientRadius(int radius) { + mGradientRadius = radius; + return this; + } + + @Override + public int getGradientRadius() { + return mGradientRadius; + } + + @Override + public ShapeView setStrokeColor(int color) { + mStrokeColor = color; + return this; + } + + @Override + public int getStrokeColor() { + return mStrokeColor; + } + + @Override + public ShapeView setStrokeWidth(int width) { + mStrokeWidth = width; + return this; + } + + @Override + public int getStrokeWidth() { + return mStrokeWidth; + } + + @Override + public ShapeView setDashWidth(int width) { + mDashWidth = width; + return this; + } + + @Override + public int getDashWidth() { + return mDashWidth; + } + + @Override + public ShapeView setDashGap(int gap) { + mDashGap = gap; + return this; + } + + @Override + public int getDashGap() { + return mDashGap; + } + + @Override + public void into() { + setBackground(build()); + } +} \ No newline at end of file diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml new file mode 100644 index 0000000..c43eddc --- /dev/null +++ b/library/src/main/res/values/attrs.xml @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/picture/1.jpg b/picture/1.jpg new file mode 100644 index 0000000..eac2dc8 Binary files /dev/null and b/picture/1.jpg differ diff --git a/picture/2.jpg b/picture/2.jpg new file mode 100644 index 0000000..af690e7 Binary files /dev/null and b/picture/2.jpg differ diff --git a/picture/3.jpg b/picture/3.jpg new file mode 100644 index 0000000..157ebfb Binary files /dev/null and b/picture/3.jpg differ diff --git a/picture/4.jpg b/picture/4.jpg new file mode 100644 index 0000000..006ece4 Binary files /dev/null and b/picture/4.jpg differ diff --git a/picture/5.jpg b/picture/5.jpg new file mode 100644 index 0000000..c21a326 Binary files /dev/null and b/picture/5.jpg differ diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..3306997 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app', ':library'