Repository: bigmanLau/CardviewFix
Branch: master
Commit: 67a525e19b6a
Files: 35
Total size: 94.4 KB
Directory structure:
gitextract_hvc7vbzt/
├── .gitattributes
├── .gitignore
├── .idea/
│ ├── gradle.xml
│ ├── misc.xml
│ └── runConfigurations.xml
├── LICENSE
├── README.md
├── build.gradle
├── cardviewlibrary/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── bigman/
│ │ └── wmzx/
│ │ └── cardviewlibrary/
│ │ └── ExampleInstrumentedTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── bigman/
│ │ │ └── wmzx/
│ │ │ └── cardviewlibrary/
│ │ │ └── library/
│ │ │ ├── CardView.kt
│ │ │ ├── CardViewApi17Impl.kt
│ │ │ ├── CardViewApi21Impl.kt
│ │ │ ├── CardViewBaseImpl.java
│ │ │ ├── CardViewDelegate.java
│ │ │ ├── CardViewImpl.kt
│ │ │ ├── RoundRectDrawable.java
│ │ │ └── RoundRectDrawableWithShadow.kt
│ │ └── res/
│ │ ├── drawable/
│ │ │ ├── green_bg.xml
│ │ │ ├── ic_launcher_background.xml
│ │ │ ├── ic_launcher_foreground.xml
│ │ │ └── shape_round_orange_bg.xml
│ │ └── values/
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ └── strings.xml
│ └── test/
│ └── java/
│ └── com/
│ └── bigman/
│ └── wmzx/
│ └── cardviewlibrary/
│ └── ExampleUnitTest.java
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Auto detect text files and perform LF normalization
* text=auto
================================================
FILE: .gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
.idea/modules.xml
.idea/vcs.xml
.idea/modules.xml
.idea/modules.xml
================================================
FILE: .idea/gradle.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/cardviewlibrary" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
================================================
FILE: .idea/misc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
================================================
FILE: .idea/runConfigurations.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
================================================
FILE: LICENSE
================================================
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.
================================================
FILE: README.md
================================================
# CardviewFix 简书地址 [https://www.jianshu.com/p/8c8b2708bdb4]
##### 原生的CardView虽然好,但是公司UI设计必须修改阴影颜色
这个库是基于google官方库,所以基本属性相同,增加三个属性,暂时只支持xml配置,分别是`startColor`,`endColor`,`topDelta`,意思是支持修改渐变颜色值,而`topDelta`是1.0.1版本加进来支持修改上下阴影比例的,取值范围是-1到1的浮点值,具体效果可以看截图
>demo在另一个项目https://github.com/bigmanLau/Tablayout 去吧比卡丘
依赖方式
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
````
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
````
Step 2. Add the dependency
````
dependencies {
implementation 'com.github.bigmanLau:CardviewFix:1.0.3'
}
````
效果图如下

第一个item就是topDelta等于-1的效果,第二个item是topDelta等于0的效果,第三个item是topDelta等于1的效果
>*注意:这个偏移量和cardCornerRadius的值有关,最大值就是cardCornerRadius的值,其实就是设置cardCornerRadius的百分比*
##### 有些同学不喜欢我贴代码,那么直接上我的github地址去看
具体原理看代码
[github地址] (https://github.com/bigmanLau/CardviewFix)
>注意问题
>1. 如果出现黑边 需要修改主题为` <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">`
>2.其他属性用法和原生的一样
>3.如果出现白边请用cardview的请设置` app:cardPreventCornerOverlap="false"`
请关注我的公众号,有很多免费信息和优秀小程序

================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: cardviewlibrary/.gitignore
================================================
/build
================================================
FILE: cardviewlibrary/build.gradle
================================================
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "com.android.support:cardview-v7:26.1.0"
}
================================================
FILE: cardviewlibrary/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# 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
================================================
FILE: cardviewlibrary/src/androidTest/java/com/bigman/wmzx/cardviewlibrary/ExampleInstrumentedTest.java
================================================
package com.bigman.wmzx.cardviewlibrary;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.bigman.wmzx.cardviewlibrary.test", appContext.getPackageName());
}
}
================================================
FILE: cardviewlibrary/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bigman.wmzx.cardviewlibrary" />
================================================
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardView.kt
================================================
package com.bigman.wmzx.customcardview.library
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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.
*/
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.os.Build
import android.support.annotation.ColorInt
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import com.bigman.wmzx.cardviewlibrary.R
import com.bigman.wmzx.cardviewlibrary.library.CardViewBaseImpl
import com.bigman.wmzx.cardviewlibrary.library.CardViewDelegate
import com.bigman.wmzx.cardviewlibrary.library.CardViewApi21Impl
/**
* A FrameLayout with a rounded corner background and shadow.
*
*
* CardView uses `elevation` property on Lollipop for shadows and falls back to a
* custom emulated shadow implementation on older platforms.
*
*
* Due to expensive nature of rounded corner clipping, on platforms before Lollipop, CardView does
* not clip its children that intersect with rounded corners. Instead, it adds padding to avoid such
* intersection (See [.setPreventCornerOverlap] to change this behavior).
*
*
* Before Lollipop, CardView adds padding to its content and draws shadows to that area. This
* padding amount is equal to `maxCardElevation + (1 - cos45) * cornerRadius` on the
* sides and `maxCardElevation * 1.5 + (1 - cos45) * cornerRadius` on top and bottom.
*
*
* Since padding is used to offset content for shadows, you cannot set padding on CardView.
* Instead, you can use content padding attributes in XML or
* [.setContentPadding] in code to set the padding between the edges of
* the CardView and children of CardView.
*
*
* Note that, if you specify exact dimensions for the CardView, because of the shadows, its content
* area will be different between platforms before Lollipop and after Lollipop. By using api version
* specific resource values, you can avoid these changes. Alternatively, If you want CardView to add
* inner padding on platforms Lollipop and after as well, you can call
* [.setUseCompatPadding] and pass `true`.
*
*
* To change CardView's elevation in a backward compatible way, use
* [.setCardElevation]. CardView will use elevation API on Lollipop and before
* Lollipop, it will change the shadow size. To avoid moving the View while shadow size is changing,
* shadow size is clamped by [.getMaxCardElevation]. If you want to change elevation
* dynamically, you should call [.setMaxCardElevation] when CardView is initialized.
*
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardBackgroundColor
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardCornerRadius
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardElevation
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardMaxElevation
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardUseCompatPadding
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardPreventCornerOverlap
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPadding
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPaddingLeft
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPaddingTop
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPaddingRight
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPaddingBottom
*/
class CardView : FrameLayout {
private var mCompatPadding: Boolean = false
private var mPreventCornerOverlap: Boolean = false
/**
* CardView requires to have a particular minimum size to draw shadows before API 21. If
* developer also sets min width/height, they might be overridden.
*
* CardView works around this issue by recording user given parameters and using an internal
* method to set them.
*/
internal var mUserSetMinWidth: Int = 0
internal var mUserSetMinHeight: Int = 0
internal val mContentPadding = Rect()
internal val mShadowBounds = Rect()
private var mEndColor: Int = 0
private var mStartColor: Int = 0
/**
* Returns whether CardView will add inner padding on platforms Lollipop and after.
*
* @return `true` if CardView adds inner padding on platforms Lollipop and after to
* have same dimensions with platforms before Lollipop.
*/
/**
* CardView adds additional padding to draw shadows on platforms before Lollipop.
*
*
* This may cause Cards to have different sizes between Lollipop and before Lollipop. If you
* need to align CardView with other Views, you may need api version specific dimension
* resources to account for the changes.
* As an alternative, you can set this flag to `true` and CardView will add the same
* padding values on platforms Lollipop and after.
*
*
* Since setting this flag to true adds unnecessary gaps in the UI, default value is
* `false`.
*
* @param useCompatPadding `true>` if CardView should add padding for the shadows on
* platforms Lollipop and above.
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardUseCompatPadding
*/
var useCompatPadding: Boolean
get() = mCompatPadding
set(useCompatPadding) {
if (mCompatPadding != useCompatPadding) {
mCompatPadding = useCompatPadding
IMPL.onCompatPaddingChanged(mCardViewDelegate)
}
}
/**
* Returns the background color state list of the CardView.
*
* @return The background color state list of the CardView.
*/
val cardBackgroundColor: ColorStateList
get() = IMPL.getBackgroundColor(mCardViewDelegate)
/**
* Returns the inner padding after the Card's left edge
*
* @return the inner padding after the Card's left edge
*/
val contentPaddingLeft: Int
get() = mContentPadding.left
/**
* Returns the inner padding before the Card's right edge
*
* @return the inner padding before the Card's right edge
*/
val contentPaddingRight: Int
get() = mContentPadding.right
/**
* Returns the inner padding after the Card's top edge
*
* @return the inner padding after the Card's top edge
*/
val contentPaddingTop: Int
get() = mContentPadding.top
/**
* Returns the inner padding before the Card's bottom edge
*
* @return the inner padding before the Card's bottom edge
*/
val contentPaddingBottom: Int
get() = mContentPadding.bottom
/**
* Returns the corner radius of the CardView.
*
* @return Corner radius of the CardView
* @see .getRadius
*/
/**
* Updates the corner radius of the CardView.
*
* @param radius The radius in pixels of the corners of the rectangle shape
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardCornerRadius
* @see .setRadius
*/
var radius: Float
get() = IMPL.getRadius(mCardViewDelegate)
set(radius) = IMPL.setRadius(mCardViewDelegate, radius)
/**
* Returns the backward compatible elevation of the CardView.
*
* @return Elevation of the CardView
* @see .setCardElevation
* @see .getMaxCardElevation
*/
/**
* Updates the backward compatible elevation of the CardView.
*
* @param elevation The backward compatible elevation in pixels.
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardElevation
* @see .getCardElevation
* @see .setMaxCardElevation
*/
var cardElevation: Float
get() = IMPL.getElevation(mCardViewDelegate)
set(elevation) = IMPL.setElevation(mCardViewDelegate, elevation)
/**
* Returns the backward compatible maximum elevation of the CardView.
*
* @return Maximum elevation of the CardView
* @see .setMaxCardElevation
* @see .getCardElevation
*/
/**
* Updates the backward compatible maximum elevation of the CardView.
*
*
* Calling this method has no effect if device OS version is Lollipop or newer and
* [.getUseCompatPadding] is `false`.
*
* @param maxElevation The backward compatible maximum elevation in pixels.
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardMaxElevation
* @see .setCardElevation
* @see .getMaxCardElevation
*/
var maxCardElevation: Float
get() = IMPL.getMaxElevation(mCardViewDelegate)
set(maxElevation) = IMPL.setMaxElevation(mCardViewDelegate, maxElevation)
/**
* Returns whether CardView should add extra padding to content to avoid overlaps with rounded
* corners on pre-Lollipop platforms.
*
* @return True if CardView prevents overlaps with rounded corners on platforms before Lollipop.
* Default value is `true`.
*/
/**
* On pre-Lollipop platforms, CardView does not clip the bounds of the Card for the rounded
* corners. Instead, it adds padding to content so that it won't overlap with the rounded
* corners. You can disable this behavior by setting this field to `false`.
*
*
* Setting this value on Lollipop and above does not have any effect unless you have enabled
* compatibility padding.
*
* @param preventCornerOverlap Whether CardView should add extra padding to content to avoid
* overlaps with the CardView corners.
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardPreventCornerOverlap
* @see .setUseCompatPadding
*/
var preventCornerOverlap: Boolean
get() = mPreventCornerOverlap
set(preventCornerOverlap) {
if (preventCornerOverlap != mPreventCornerOverlap) {
mPreventCornerOverlap = preventCornerOverlap
IMPL.onPreventCornerOverlapChanged(mCardViewDelegate)
}
}
private val mCardViewDelegate = object : CardViewDelegate {
private var mCardBackground: Drawable? = null
override fun setCardBackground(drawable: Drawable) {
mCardBackground = drawable
setBackgroundDrawable(drawable)
}
override fun getUseCompatPadding(): Boolean {
return this@CardView.useCompatPadding
}
override fun getPreventCornerOverlap(): Boolean {
return this@CardView.preventCornerOverlap
}
override fun setShadowPadding(left: Int, top: Int, right: Int, bottom: Int) {
mShadowBounds.set(left, top, right, bottom)
super@CardView.setPadding(left + mContentPadding.left, top + mContentPadding.top,
right + mContentPadding.right, bottom + mContentPadding.bottom)
}
override fun setMinWidthHeightInternal(width: Int, height: Int) {
if (width > mUserSetMinWidth) {
super@CardView.setMinimumWidth(width)
}
if (height > mUserSetMinHeight) {
super@CardView.setMinimumHeight(height)
}
}
override fun getCardBackground(): Drawable? {
return mCardBackground
}
override fun getCardView(): View {
return this@CardView
}
}
constructor(context: Context) : super(context) {
initialize(context, null, 0)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
initialize(context, attrs, 0)
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
initialize(context, attrs, defStyleAttr)
}
override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) {
// NO OP
}
override fun setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int) {
// NO OP
}
/**
* Sets the padding between the Card's edges and the children of CardView.
*
*
* Depending on platform version or [.getUseCompatPadding] settings, CardView may
* update these values before calling [View.setPadding].
*
* @param left The left padding in pixels
* @param top The top padding in pixels
* @param right The right padding in pixels
* @param bottom The bottom padding in pixels
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPadding
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPaddingLeft
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPaddingTop
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPaddingRight
* @attr ref android.support.v7.cardview.R.styleable#CardView_contentPaddingBottom
*/
fun setContentPadding(left: Int, top: Int, right: Int, bottom: Int) {
mContentPadding.set(left, top, right, bottom)
IMPL.updatePadding(mCardViewDelegate)
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
var widthMeasureSpec = widthMeasureSpec
var heightMeasureSpec = heightMeasureSpec
if (IMPL !is CardViewApi21Impl) {
val widthMode = View.MeasureSpec.getMode(widthMeasureSpec)
when (widthMode) {
View.MeasureSpec.EXACTLY, View.MeasureSpec.AT_MOST -> {
val minWidth = Math.ceil(IMPL.getMinWidth(mCardViewDelegate).toDouble()).toInt()
widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(Math.max(minWidth,
View.MeasureSpec.getSize(widthMeasureSpec)), widthMode)
}
View.MeasureSpec.UNSPECIFIED -> {
}
}// Do nothing
val heightMode = View.MeasureSpec.getMode(heightMeasureSpec)
when (heightMode) {
View.MeasureSpec.EXACTLY, View.MeasureSpec.AT_MOST -> {
val minHeight = Math.ceil(IMPL.getMinHeight(mCardViewDelegate).toDouble()).toInt()
heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(Math.max(minHeight,
View.MeasureSpec.getSize(heightMeasureSpec)), heightMode)
}
View.MeasureSpec.UNSPECIFIED -> {
}
}// Do nothing
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
}
}
private var mTopDelta: Float=1f
private fun initialize(context: Context, attrs: AttributeSet?, defStyleAttr: Int) {
val a = context.obtainStyledAttributes(attrs, R.styleable.CardView, defStyleAttr,
R.style.CardView)
val backgroundColor: ColorStateList?
if (a.hasValue(R.styleable.CardView_cardBackgroundColor)) {
backgroundColor = a.getColorStateList(R.styleable.CardView_cardBackgroundColor)
} else {
// There isn't one set, so we'll compute one based on the theme
val aa = getContext().obtainStyledAttributes(COLOR_BACKGROUND_ATTR)
val themeColorBackground = aa.getColor(0, 0)
aa.recycle()
// If the theme colorBackground is light, use our own light color, otherwise dark
val hsv = FloatArray(3)
Color.colorToHSV(themeColorBackground, hsv)
backgroundColor = ColorStateList.valueOf(if (hsv[2] > 0.5f)
resources.getColor(R.color.cardview_light_background)
else
resources.getColor(R.color.cardview_dark_background))
}
val radius = a.getDimension(R.styleable.CardView_cardCornerRadius, 0f)
val elevation = a.getDimension(R.styleable.CardView_cardElevation, 0f)
var maxElevation = a.getDimension(R.styleable.CardView_cardMaxElevation, 0f)
mCompatPadding = a.getBoolean(R.styleable.CardView_cardUseCompatPadding, false)
mPreventCornerOverlap = a.getBoolean(R.styleable.CardView_cardPreventCornerOverlap, true)
val defaultPadding = a.getDimensionPixelSize(R.styleable.CardView_contentPadding, 0)
mContentPadding.left = a.getDimensionPixelSize(R.styleable.CardView_contentPaddingLeft,
defaultPadding)
mContentPadding.top = a.getDimensionPixelSize(R.styleable.CardView_contentPaddingTop,
defaultPadding)
mContentPadding.right = a.getDimensionPixelSize(R.styleable.CardView_contentPaddingRight,
defaultPadding)
mContentPadding.bottom = a.getDimensionPixelSize(R.styleable.CardView_contentPaddingBottom,
defaultPadding)
if (elevation > maxElevation) {
maxElevation = elevation
}
mUserSetMinWidth = a.getDimensionPixelSize(R.styleable.CardView_android_minWidth, 0)
mUserSetMinHeight = a.getDimensionPixelSize(R.styleable.CardView_android_minHeight, 0)
a.recycle()
val a2 = context.obtainStyledAttributes(attrs, R.styleable.CardViewShadow)
val n = a2.indexCount
if(a2.hasValue(R.styleable.CardViewShadow_topDelta)){
mTopDelta=a2.getFloat(R.styleable.CardViewShadow_topDelta,0f)
}
if (a2.hasValue(R.styleable.CardViewShadow_endColor) && a2.hasValue(R.styleable.CardViewShadow_startColor)) {
for (i in 0 until n) {
val attr = a.getIndex(i)
when (attr) {
R.styleable.CardViewShadow_endColor -> mEndColor = a.getColor(attr, resources.getColor(R.color.cardview_shadow_end_color))
R.styleable.CardViewShadow_startColor -> mStartColor = a.getColor(attr, resources.getColor(R.color.cardview_shadow_start_color))
}
}
IMPL.initialize(mCardViewDelegate, context, backgroundColor, radius,
elevation, maxElevation, mStartColor, mEndColor,mTopDelta)
} else {
IMPL.initialize(mCardViewDelegate, context, backgroundColor, radius,
elevation, maxElevation,mTopDelta)
}
}
override fun setMinimumWidth(minWidth: Int) {
mUserSetMinWidth = minWidth
super.setMinimumWidth(minWidth)
}
override fun setMinimumHeight(minHeight: Int) {
mUserSetMinHeight = minHeight
super.setMinimumHeight(minHeight)
}
/**
* Updates the background color of the CardView
*
* @param color The new color to set for the card background
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardBackgroundColor
*/
fun setCardBackgroundColor(@ColorInt color: Int) {
IMPL.setBackgroundColor(mCardViewDelegate, ColorStateList.valueOf(color))
}
/**
* Updates the background ColorStateList of the CardView
*
* @param color The new ColorStateList to set for the card background
* @attr ref android.support.v7.cardview.R.styleable#CardView_cardBackgroundColor
*/
fun setCardBackgroundColor(color: ColorStateList?) {
IMPL.setBackgroundColor(mCardViewDelegate, color)
}
companion object {
private val COLOR_BACKGROUND_ATTR = intArrayOf(android.R.attr.colorBackground)
private val IMPL: CardViewImpl = if (Build.VERSION.SDK_INT >= 17) {
CardViewApi17Impl()
} else {
CardViewBaseImpl()
}
init {
IMPL.initStatic()
}
}
}
================================================
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewApi17Impl.kt
================================================
package com.bigman.wmzx.customcardview.library
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF
import com.bigman.wmzx.cardviewlibrary.library.CardViewBaseImpl
import com.bigman.wmzx.cardviewlibrary.library.CardViewDelegate
/**
* create by bigman
* create date == 2018/7/10
* create time == 15:48
*/
internal class CardViewApi17Impl : CardViewBaseImpl() {
override fun initStatic() {
RoundRectDrawableWithShadow.sRoundRectHelper = object : RoundRectDrawableWithShadow.RoundRectHelper {
override fun drawRoundRect(canvas: Canvas, bounds: RectF, cornerRadius: Float, paint: Paint?) {
canvas.drawRoundRect(bounds, cornerRadius, cornerRadius, paint)
}
}
}
}
================================================
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewApi21Impl.kt
================================================
package com.bigman.wmzx.cardviewlibrary.library
import android.content.Context
import android.content.res.ColorStateList
import android.support.annotation.RequiresApi
import com.bigman.wmzx.customcardview.library.CardViewImpl
import com.bigman.wmzx.customcardview.library.RoundRectDrawableWithShadow
/**
* create by bigman
* create date == 2018/7/26
* create time == 15:46
*/
@RequiresApi(21)
internal class CardViewApi21Impl : CardViewImpl {
override fun initialize(cardViewDelegate: CardViewDelegate, context: Context, backgroundColor: ColorStateList,
radius: Float, elevation: Float, maxElevation: Float, startColor: Int, endColor: Int, topDelta: Float) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun initialize(cardView: CardViewDelegate, context: Context, backgroundColor: ColorStateList, radius: Float
, elevation: Float, maxElevation: Float, topDelta: Float) {
val background = RoundRectDrawable(backgroundColor, radius)
cardView.cardBackground = background
val view = cardView.cardView
view.clipToOutline = true
view.elevation = elevation
setMaxElevation(cardView, maxElevation)
}
override fun setRadius(cardView: CardViewDelegate, radius: Float) {
getCardBackground(cardView).radius = radius
}
override fun initStatic() {}
override fun setMaxElevation(cardView: CardViewDelegate, maxElevation: Float) {
getCardBackground(cardView).setPadding(maxElevation,
cardView.useCompatPadding, cardView.preventCornerOverlap)
updatePadding(cardView)
}
override fun getMaxElevation(cardView: CardViewDelegate): Float {
return getCardBackground(cardView).padding
}
override fun getMinWidth(cardView: CardViewDelegate): Float {
return getRadius(cardView) * 2
}
override fun getMinHeight(cardView: CardViewDelegate): Float {
return getRadius(cardView) * 2
}
override fun getRadius(cardView: CardViewDelegate): Float {
return getCardBackground(cardView).radius
}
override fun setElevation(cardView: CardViewDelegate, elevation: Float) {
cardView.cardView.elevation = elevation
}
override fun getElevation(cardView: CardViewDelegate): Float {
return cardView.cardView.elevation
}
override fun updatePadding(cardView: CardViewDelegate) {
if (!cardView.useCompatPadding) {
cardView.setShadowPadding(0, 0, 0, 0)
return
}
val elevation = getMaxElevation(cardView)
val radius = getRadius(cardView)
val hPadding = Math.ceil(RoundRectDrawableWithShadow
.calculateHorizontalPadding(elevation, radius, cardView.preventCornerOverlap).toDouble()).toInt()
val vPadding = Math.ceil(RoundRectDrawableWithShadow
.calculateVerticalPadding(elevation, radius, cardView.preventCornerOverlap).toDouble()).toInt()
cardView.setShadowPadding(hPadding, vPadding, hPadding, vPadding)
}
override fun onCompatPaddingChanged(cardView: CardViewDelegate) {
setMaxElevation(cardView, getMaxElevation(cardView))
}
override fun onPreventCornerOverlapChanged(cardView: CardViewDelegate) {
setMaxElevation(cardView, getMaxElevation(cardView))
}
override fun setBackgroundColor(cardView: CardViewDelegate, color: ColorStateList?) {
getCardBackground(cardView).color = color
}
override fun getBackgroundColor(cardView: CardViewDelegate): ColorStateList {
return getCardBackground(cardView).color
}
private fun getCardBackground(cardView: CardViewDelegate): RoundRectDrawable {
return cardView.cardBackground as RoundRectDrawable
}
}
================================================
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewBaseImpl.java
================================================
package com.bigman.wmzx.cardviewlibrary.library;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Rect;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import com.bigman.wmzx.customcardview.library.CardViewImpl;
import com.bigman.wmzx.customcardview.library.RoundRectDrawableWithShadow;
public class CardViewBaseImpl implements CardViewImpl {
private final RectF mCornerRect = new RectF();
@Override
public void initStatic() {
// Draws a round rect using 7 draw operations. This is faster than using
// canvas.drawRoundRect before JBMR1 because API 11-16 used alpha mask textures to draw
// shapes.
RoundRectDrawableWithShadow.Companion.setSRoundRectHelper((canvas, bounds, cornerRadius, paint) -> {
final float twoRadius = cornerRadius * 2;
final float innerWidth = bounds.width() - twoRadius - 1;
final float innerHeight = bounds.height() - twoRadius - 1;
if (cornerRadius >= 1f) {
// increment corner radius to account for half pixels.
float roundedCornerRadius = cornerRadius + .5f;
mCornerRect.set(-roundedCornerRadius, -roundedCornerRadius, roundedCornerRadius,
roundedCornerRadius);
int saved = canvas.save();
canvas.translate(bounds.left + roundedCornerRadius,
bounds.top + roundedCornerRadius);
canvas.drawArc(mCornerRect, 180, 90, true, paint);
canvas.translate(innerWidth, 0);
canvas.rotate(90);
canvas.drawArc(mCornerRect, 180, 90, true, paint);
canvas.translate(innerHeight, 0);
canvas.rotate(90);
canvas.drawArc(mCornerRect, 180, 90, true, paint);
canvas.translate(innerWidth, 0);
canvas.rotate(90);
canvas.drawArc(mCornerRect, 180, 90, true, paint);
canvas.restoreToCount(saved);
//draw top and bottom pieces
canvas.drawRect(bounds.left + roundedCornerRadius - 1f, bounds.top,
bounds.right - roundedCornerRadius + 1f,
bounds.top + roundedCornerRadius, paint);
canvas.drawRect(bounds.left + roundedCornerRadius - 1f,
bounds.bottom - roundedCornerRadius,
bounds.right - roundedCornerRadius + 1f, bounds.bottom, paint);
}
// center
canvas.drawRect(bounds.left, bounds.top + cornerRadius,
bounds.right, bounds.bottom - cornerRadius, paint);
});
}
@Override
public void initialize(CardViewDelegate cardView, Context context,
ColorStateList backgroundColor, float radius, float elevation, float maxElevation,float topDelta) {
RoundRectDrawableWithShadow background = createBackground(context, backgroundColor, radius,
elevation, maxElevation,topDelta);
background.setAddPaddingForCorners(cardView.getPreventCornerOverlap());
cardView.setCardBackground(background);
updatePadding(cardView);
}
private RoundRectDrawableWithShadow createBackground(Context context,
ColorStateList backgroundColor, float radius, float elevation,
float maxElevation,float topDelta) {
return new RoundRectDrawableWithShadow(context.getResources(), backgroundColor, radius,
elevation, maxElevation,topDelta);
}
@Override
public void updatePadding(CardViewDelegate cardView) {
Rect shadowPadding = new Rect();
getShadowBackground(cardView).getMaxShadowAndCornerPadding(shadowPadding);
cardView.setMinWidthHeightInternal((int) Math.ceil(getMinWidth(cardView)),
(int) Math.ceil(getMinHeight(cardView)));
cardView.setShadowPadding(shadowPadding.left, shadowPadding.top,
shadowPadding.right, shadowPadding.bottom);
}
@Override
public void onCompatPaddingChanged(CardViewDelegate cardView) {
// NO OP
}
@Override
public void onPreventCornerOverlapChanged(CardViewDelegate cardView) {
getShadowBackground(cardView).setAddPaddingForCorners(cardView.getPreventCornerOverlap());
updatePadding(cardView);
}
@Override
public void setBackgroundColor(CardViewDelegate cardView, @Nullable ColorStateList color) {
getShadowBackground(cardView).setColor(color);
}
@Override
public ColorStateList getBackgroundColor(CardViewDelegate cardView) {
return getShadowBackground(cardView).getColor();
}
@Override
public void initialize(CardViewDelegate cardView, Context context,
ColorStateList backgroundColor, float radius, float elevation,
float maxElevation, int startColor, int endColor,float topDelta) {
RoundRectDrawableWithShadow background = createBackground(context, backgroundColor, radius,
elevation, maxElevation,startColor,endColor,topDelta);
background.setAddPaddingForCorners(cardView.getPreventCornerOverlap());
cardView.setCardBackground(background);
updatePadding(cardView);
}
private RoundRectDrawableWithShadow createBackground(Context context, ColorStateList backgroundColor,
float radius, float elevation, float maxElevation,
int startColor, int endColor,float topDelta) {
return new RoundRectDrawableWithShadow(context.getResources(), backgroundColor, radius,
elevation, maxElevation,startColor,endColor,topDelta);
}
@Override
public void setRadius(CardViewDelegate cardView, float radius) {
getShadowBackground(cardView).setCornerRadius(radius);
updatePadding(cardView);
}
@Override
public float getRadius(CardViewDelegate cardView) {
return getShadowBackground(cardView).getCornerRadius();
}
@Override
public void setElevation(CardViewDelegate cardView, float elevation) {
getShadowBackground(cardView).setShadowSize(elevation);
}
@Override
public float getElevation(CardViewDelegate cardView) {
return getShadowBackground(cardView).getShadowSize();
}
@Override
public void setMaxElevation(CardViewDelegate cardView, float maxElevation) {
getShadowBackground(cardView).setMaxShadowSize(maxElevation);
updatePadding(cardView);
}
@Override
public float getMaxElevation(CardViewDelegate cardView) {
return getShadowBackground(cardView).getMaxShadowSize();
}
@Override
public float getMinWidth(CardViewDelegate cardView) {
return getShadowBackground(cardView).getMinWidth();
}
@Override
public float getMinHeight(CardViewDelegate cardView) {
return getShadowBackground(cardView).getMinHeight();
}
private RoundRectDrawableWithShadow getShadowBackground(CardViewDelegate cardView) {
return ((RoundRectDrawableWithShadow) cardView.getCardBackground());
}
}
================================================
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewDelegate.java
================================================
package com.bigman.wmzx.cardviewlibrary.library;
import android.graphics.drawable.Drawable;
import android.view.View;
/**
* create by bigman
* create date == 2018/7/10
* create time == 11:01
*/
public interface CardViewDelegate {
void setCardBackground(Drawable drawable);
Drawable getCardBackground();
boolean getUseCompatPadding();
boolean getPreventCornerOverlap();
void setShadowPadding(int left, int top, int right, int bottom);
void setMinWidthHeightInternal(int width, int height);
View getCardView();
}
================================================
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewImpl.kt
================================================
package com.bigman.wmzx.customcardview.library
import android.content.Context
import android.content.res.ColorStateList
import com.bigman.wmzx.cardviewlibrary.library.CardViewDelegate
internal interface CardViewImpl {
fun initialize(cardView: CardViewDelegate, context: Context, backgroundColor: ColorStateList,
radius: Float, elevation: Float, maxElevation: Float, topDelta: Float)
fun setRadius(cardView: CardViewDelegate, radius: Float)
fun getRadius(cardView: CardViewDelegate): Float
fun setElevation(cardView: CardViewDelegate, elevation: Float)
fun getElevation(cardView: CardViewDelegate): Float
fun initStatic()
fun setMaxElevation(cardView: CardViewDelegate, maxElevation: Float)
fun getMaxElevation(cardView: CardViewDelegate): Float
fun getMinWidth(cardView: CardViewDelegate): Float
fun getMinHeight(cardView: CardViewDelegate): Float
fun updatePadding(cardView: CardViewDelegate)
fun onCompatPaddingChanged(cardView: CardViewDelegate)
fun onPreventCornerOverlapChanged(cardView: CardViewDelegate)
fun setBackgroundColor(cardView: CardViewDelegate, color: ColorStateList?)
fun getBackgroundColor(cardView: CardViewDelegate): ColorStateList
fun initialize(cardViewDelegate: CardViewDelegate, context: Context,
backgroundColor: ColorStateList, radius: Float, elevation: Float
, maxElevation: Float, startColor: Int, endColor: Int, topDelta: Float)
}
================================================
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/RoundRectDrawable.java
================================================
package com.bigman.wmzx.cardviewlibrary.library;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import com.bigman.wmzx.customcardview.library.RoundRectDrawableWithShadow;
/**
* Very simple drawable that draws a rounded rectangle background with arbitrary corners and also
* reports proper outline for Lollipop.
* <p>
* Simpler and uses less resources compared to GradientDrawable or ShapeDrawable.
*/
@RequiresApi(21)
public class RoundRectDrawable extends Drawable {
private float mRadius;
private final Paint mPaint;
private final RectF mBoundsF;
private final Rect mBoundsI;
private float mPadding;
private boolean mInsetForPadding = false;
private boolean mInsetForRadius = true;
private ColorStateList mBackground;
private PorterDuffColorFilter mTintFilter;
private ColorStateList mTint;
private PorterDuff.Mode mTintMode = PorterDuff.Mode.SRC_IN;
public RoundRectDrawable(ColorStateList backgroundColor, float radius) {
mRadius = radius;
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
setBackground(backgroundColor);
mBoundsF = new RectF();
mBoundsI = new Rect();
}
private void setBackground(ColorStateList color) {
mBackground = (color == null) ? ColorStateList.valueOf(Color.TRANSPARENT) : color;
mPaint.setColor(mBackground.getColorForState(getState(), mBackground.getDefaultColor()));
}
void setPadding(float padding, boolean insetForPadding, boolean insetForRadius) {
if (padding == mPadding && mInsetForPadding == insetForPadding
&& mInsetForRadius == insetForRadius) {
return;
}
mPadding = padding;
mInsetForPadding = insetForPadding;
mInsetForRadius = insetForRadius;
updateBounds(null);
invalidateSelf();
}
float getPadding() {
return mPadding;
}
@Override
public void draw(Canvas canvas) {
final Paint paint = mPaint;
final boolean clearColorFilter;
if (mTintFilter != null && paint.getColorFilter() == null) {
paint.setColorFilter(mTintFilter);
clearColorFilter = true;
} else {
clearColorFilter = false;
}
canvas.drawRoundRect(mBoundsF, mRadius, mRadius, paint);
if (clearColorFilter) {
paint.setColorFilter(null);
}
}
private void updateBounds(Rect bounds) {
if (bounds == null) {
bounds = getBounds();
}
mBoundsF.set(bounds.left, bounds.top, bounds.right, bounds.bottom);
mBoundsI.set(bounds);
if (mInsetForPadding) {
float vInset = RoundRectDrawableWithShadow.Companion.calculateVerticalPadding(mPadding, mRadius, mInsetForRadius);
float hInset = RoundRectDrawableWithShadow.Companion.calculateHorizontalPadding(mPadding, mRadius, mInsetForRadius);
mBoundsI.inset((int) Math.ceil(hInset), (int) Math.ceil(vInset));
// to make sure they have same bounds.
mBoundsF.set(mBoundsI);
}
}
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
updateBounds(bounds);
}
@Override
public void getOutline(Outline outline) {
outline.setRoundRect(mBoundsI, mRadius);
}
void setRadius(float radius) {
if (radius == mRadius) {
return;
}
mRadius = radius;
updateBounds(null);
invalidateSelf();
}
@Override
public void setAlpha(int alpha) {
mPaint.setAlpha(alpha);
}
@Override
public void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
}
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
public float getRadius() {
return mRadius;
}
public void setColor(@Nullable ColorStateList color) {
setBackground(color);
invalidateSelf();
}
public ColorStateList getColor() {
return mBackground;
}
@Override
public void setTintList(ColorStateList tint) {
mTint = tint;
mTintFilter = createTintFilter(mTint, mTintMode);
invalidateSelf();
}
@Override
public void setTintMode(PorterDuff.Mode tintMode) {
mTintMode = tintMode;
mTintFilter = createTintFilter(mTint, mTintMode);
invalidateSelf();
}
@Override
protected boolean onStateChange(int[] stateSet) {
final int newColor = mBackground.getColorForState(stateSet, mBackground.getDefaultColor());
final boolean colorChanged = newColor != mPaint.getColor();
if (colorChanged) {
mPaint.setColor(newColor);
}
if (mTint != null && mTintMode != null) {
mTintFilter = createTintFilter(mTint, mTintMode);
return true;
}
return colorChanged;
}
@Override
public boolean isStateful() {
return (mTint != null && mTint.isStateful())
|| (mBackground != null && mBackground.isStateful()) || super.isStateful();
}
/**
* Ensures the tint filter is consistent with the current tint color and
* mode.
*/
private PorterDuffColorFilter createTintFilter(ColorStateList tint, PorterDuff.Mode tintMode) {
if (tint == null || tintMode == null) {
return null;
}
final int color = tint.getColorForState(getState(), Color.TRANSPARENT);
return new PorterDuffColorFilter(color, tintMode);
}
}
================================================
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/RoundRectDrawableWithShadow.kt
================================================
package com.bigman.wmzx.customcardview.library
import android.content.res.ColorStateList
import android.content.res.Resources
import android.graphics.*
import android.graphics.drawable.Drawable
import com.bigman.wmzx.cardviewlibrary.R
/**
* A rounded rectangle drawable which also includes a shadow around.
*/
internal class RoundRectDrawableWithShadow : Drawable {
private val mInsetShadow: Int // extra shadow to avoid gaps between card and shadow
private var mPaint: Paint? = null
private var mCornerShadowPaint: Paint? = null
private var mEdgeShadowPaint: Paint? = null
private val mCardBounds: RectF
private var mCornerRadius: Float = 0.toFloat()
private var mCornerShadowPath: Path? = null
// actual value set by developer
private var mRawMaxShadowSize: Float = 0.toFloat()
// multiplied value to account for shadow offset
private var mShadowSize: Float = 0.toFloat()
// actual value set by developer
private var mRawShadowSize: Float = 0.toFloat()
private var mBackground: ColorStateList? = null
private var mDirty = true
private val mShadowStartColor: Int
private val mShadowEndColor: Int
private var mTopDelta: Float
private var mAddPaddingForCorners = true
/**
* If shadow size is set to a value above max shadow, we print a warning
*/
private var mPrintedShadowClipWarning = false
var cornerRadius: Float
get() = mCornerRadius
set(radius) {
var radius = radius
if (radius < 0f) {
throw IllegalArgumentException("Invalid radius $radius. Must be >= 0")
}
radius = (radius + .5f).toInt().toFloat()
if (mCornerRadius == radius) {
return
}
mCornerRadius = radius
mDirty = true
invalidateSelf()
}
var shadowSize: Float
get() = mRawShadowSize
set(size) = setShadowSize(size, mRawMaxShadowSize)
var maxShadowSize: Float
get() = mRawMaxShadowSize
set(size) = setShadowSize(mRawShadowSize, size)
val minWidth: Float
get() {
val content = 2 * Math.max(mRawMaxShadowSize, mCornerRadius + mInsetShadow.toFloat() + mRawMaxShadowSize / 2)
return content + (mRawMaxShadowSize + mInsetShadow) * 2
}
val minHeight: Float
get() {
val content = 2 * Math.max(mRawMaxShadowSize, mCornerRadius + mInsetShadow.toFloat()
+ mRawMaxShadowSize * SHADOW_MULTIPLIER / 2)
return content + (mRawMaxShadowSize * SHADOW_MULTIPLIER + mInsetShadow) * 2
}
var color: ColorStateList?
get() = mBackground
set(color) {
setBackground(color)
invalidateSelf()
}
constructor(resources: Resources, backgroundColor: ColorStateList, radius: Float,
shadowSize: Float, maxShadowSize: Float,topDelta:Float) {
mShadowStartColor = resources.getColor(R.color.cardview_shadow_start_color)
mShadowEndColor = resources.getColor(R.color.cardview_shadow_end_color)
mTopDelta =topDelta
mInsetShadow = resources.getDimensionPixelSize(R.dimen.cardview_compat_inset_shadow)
mPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.DITHER_FLAG)
setBackground(backgroundColor)
mCornerShadowPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.DITHER_FLAG)
mCornerShadowPaint!!.style = Paint.Style.FILL
mCornerRadius = (radius + .5f).toInt().toFloat()
mCardBounds = RectF()
mEdgeShadowPaint = Paint(mCornerShadowPaint)
mEdgeShadowPaint!!.isAntiAlias = false
setShadowSize(shadowSize, maxShadowSize)
}
constructor(resources: Resources, backgroundColor: ColorStateList,
radius: Float, shadowSize: Float, maxShadowSize: Float,
startColor: Int, endColor: Int,topDelta:Float) {
mShadowStartColor = startColor
mShadowEndColor = endColor
mTopDelta = topDelta
mInsetShadow = resources.getDimensionPixelSize(R.dimen.cardview_compat_inset_shadow)
mPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.DITHER_FLAG)
setBackground(backgroundColor)
mCornerShadowPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.DITHER_FLAG)
mCornerShadowPaint!!.style = Paint.Style.FILL
mCornerRadius = (radius + .5f).toInt().toFloat()
mCardBounds = RectF()
mEdgeShadowPaint = Paint(mCornerShadowPaint)
mEdgeShadowPaint!!.isAntiAlias = false
setShadowSize(shadowSize, maxShadowSize)
}
private fun setBackground(color: ColorStateList?) {
mBackground = color ?: ColorStateList.valueOf(Color.TRANSPARENT)
mPaint!!.color = mBackground!!.getColorForState(state, mBackground!!.defaultColor)
}
/**
* Casts the value to an even integer.
*/
private fun toEven(value: Float): Int {
val i = (value + .5f).toInt()
return if (i % 2 == 1) {
i - 1
} else i
}
fun setAddPaddingForCorners(addPaddingForCorners: Boolean) {
mAddPaddingForCorners = addPaddingForCorners
invalidateSelf()
}
override fun setAlpha(alpha: Int) {
mPaint!!.alpha = alpha
mCornerShadowPaint!!.alpha = alpha
mEdgeShadowPaint!!.alpha = alpha
}
override fun onBoundsChange(bounds: Rect) {
super.onBoundsChange(bounds)
mDirty = true
}
private fun setShadowSize(shadowSize: Float, maxShadowSize: Float) {
var shadowSize = shadowSize
var maxShadowSize = maxShadowSize
if (shadowSize < 0f) {
throw IllegalArgumentException("Invalid shadow size " + shadowSize
+ ". Must be >= 0")
}
if (maxShadowSize < 0f) {
throw IllegalArgumentException("Invalid max shadow size " + maxShadowSize
+ ". Must be >= 0")
}
shadowSize = toEven(shadowSize).toFloat()
maxShadowSize = toEven(maxShadowSize).toFloat()
if (shadowSize > maxShadowSize) {
shadowSize = maxShadowSize
if (!mPrintedShadowClipWarning) {
mPrintedShadowClipWarning = true
}
}
if (mRawShadowSize == shadowSize && mRawMaxShadowSize == maxShadowSize) {
return
}
mRawShadowSize = shadowSize
mRawMaxShadowSize = maxShadowSize
mShadowSize = (shadowSize * SHADOW_MULTIPLIER + mInsetShadow.toFloat() + .5f).toInt().toFloat()
mDirty = true
invalidateSelf()
}
override fun getPadding(padding: Rect): Boolean {
val vOffset = Math.ceil(calculateVerticalPadding(mRawMaxShadowSize, mCornerRadius,
mAddPaddingForCorners).toDouble()).toInt()
val hOffset = Math.ceil(calculateHorizontalPadding(mRawMaxShadowSize, mCornerRadius,
mAddPaddingForCorners).toDouble()).toInt()
padding.set(hOffset, vOffset, hOffset, vOffset)
return true
}
override fun onStateChange(stateSet: IntArray): Boolean {
val newColor = mBackground!!.getColorForState(stateSet, mBackground!!.defaultColor)
if (mPaint!!.color == newColor) {
return false
}
mPaint!!.color = newColor
mDirty = true
invalidateSelf()
return true
}
override fun isStateful(): Boolean {
return mBackground != null && mBackground!!.isStateful || super.isStateful()
}
override fun setColorFilter(cf: ColorFilter?) {
mPaint!!.colorFilter = cf
}
override fun getOpacity(): Int {
return PixelFormat.TRANSLUCENT
}
/**
* 绘制主要工作
*/
override fun draw(canvas: Canvas) {
if (mDirty) {
buildComponents(bounds)
mDirty = false
}
if(mTopDelta>1f){
mTopDelta=1f
}else if(mTopDelta>-1f&&mTopDelta<0f){
mTopDelta=-1f
}
canvas.translate(0f, mRawShadowSize / 2*mTopDelta)
drawShadow(canvas)
canvas.translate(0f, -mRawShadowSize / 2*mTopDelta)
sRoundRectHelper!!.drawRoundRect(canvas, mCardBounds, mCornerRadius, mPaint)
}
/**
* 绘制四个角阴影
*/
private fun drawShadow(canvas: Canvas) {
val edgeShadowTop = -mCornerRadius - mShadowSize
val inset = mCornerRadius + mInsetShadow.toFloat() + mRawShadowSize / 2
val drawHorizontalEdges = mCardBounds.width() - 2 * inset > 0
val drawVerticalEdges = mCardBounds.height() - 2 * inset > 0
// LT 左上
var saved = canvas.save()
canvas.translate(mCardBounds.left + inset, mCardBounds.top + inset)
canvas.drawPath(mCornerShadowPath!!, mCornerShadowPaint!!)
if (drawHorizontalEdges) {
canvas.drawRect(0f, edgeShadowTop,
mCardBounds.width() - 2 * inset, -mCornerRadius,
mEdgeShadowPaint!!)
}
canvas.restoreToCount(saved)
// RB 右下
saved = canvas.save()
canvas.translate(mCardBounds.right - inset, mCardBounds.bottom - inset)
canvas.rotate(180f)
canvas.drawPath(mCornerShadowPath!!, mCornerShadowPaint!!)
if (drawHorizontalEdges) {
canvas.drawRect(0f, edgeShadowTop,
mCardBounds.width() - 2 * inset, -mCornerRadius + mShadowSize,
mEdgeShadowPaint!!)
}
canvas.restoreToCount(saved)
// LB 左下
saved = canvas.save()
canvas.translate(mCardBounds.left + inset, mCardBounds.bottom - inset)
canvas.rotate(270f)
canvas.drawPath(mCornerShadowPath!!, mCornerShadowPaint!!)
if (drawVerticalEdges) {
canvas.drawRect(0f, edgeShadowTop,
mCardBounds.height() - 2 * inset, -mCornerRadius, mEdgeShadowPaint!!)
}
canvas.restoreToCount(saved)
// RT 右上
saved = canvas.save()
canvas.translate(mCardBounds.right - inset, mCardBounds.top + inset)
canvas.rotate(90f)
canvas.drawPath(mCornerShadowPath!!, mCornerShadowPaint!!)
if (drawVerticalEdges) {
canvas.drawRect(0f, edgeShadowTop,
mCardBounds.height() - 2 * inset, -mCornerRadius, mEdgeShadowPaint!!)
}
canvas.restoreToCount(saved)
}
private fun buildShadowCorners() {
val innerBounds = RectF(-mCornerRadius, -mCornerRadius, mCornerRadius, mCornerRadius)
val outerBounds = RectF(innerBounds)
outerBounds.inset(-mShadowSize, -mShadowSize)
if (mCornerShadowPath == null) {
mCornerShadowPath = Path()
} else {
mCornerShadowPath!!.reset()
}
mCornerShadowPath!!.fillType = Path.FillType.EVEN_ODD
mCornerShadowPath!!.moveTo(-mCornerRadius, 0f)
mCornerShadowPath!!.rLineTo(-mShadowSize, 0f)
// outer arc
mCornerShadowPath!!.arcTo(outerBounds, 180f, 90f, false)
// inner arc
mCornerShadowPath!!.arcTo(innerBounds, 270f, -90f, false)
mCornerShadowPath!!.close()
val startRatio = mCornerRadius / (mCornerRadius + mShadowSize)
mCornerShadowPaint!!.shader = RadialGradient(0f, 0f, mCornerRadius + mShadowSize,
intArrayOf(mShadowStartColor, mShadowStartColor, mShadowEndColor),
floatArrayOf(0f, startRatio, 1f),
Shader.TileMode.CLAMP)
// we offset the content shadowSize/2 pixels up to make it more realistic.
// this is why edge shadow shader has some extra space
// When drawing bottom edge shadow, we use that extra space.
mEdgeShadowPaint!!.shader = LinearGradient(0f, -mCornerRadius + mShadowSize, 0f,
-mCornerRadius - mShadowSize,
intArrayOf(mShadowStartColor, mShadowStartColor, mShadowEndColor),
floatArrayOf(0f, .5f, 1f), Shader.TileMode.CLAMP)
mEdgeShadowPaint!!.isAntiAlias = false
}
private fun buildComponents(bounds: Rect) {
// Card is offset SHADOW_MULTIPLIER * maxShadowSize to account for the shadow shift.
// We could have different top-bottom offsets to avoid extra gap above but in that case
// center aligning Views inside the CardView would be problematic.
val verticalOffset = mRawMaxShadowSize * SHADOW_MULTIPLIER
mCardBounds.set(bounds.left + mRawMaxShadowSize, bounds.top + verticalOffset,
bounds.right - mRawMaxShadowSize, bounds.bottom - verticalOffset)
buildShadowCorners()
}
fun getMaxShadowAndCornerPadding(into: Rect) {
getPadding(into)
}
internal interface RoundRectHelper {
fun drawRoundRect(canvas: Canvas, bounds: RectF, cornerRadius: Float, paint: Paint?)
}
companion object {
// used to calculate content padding
private val COS_45 = Math.cos(Math.toRadians(45.0))
private val SHADOW_MULTIPLIER = 1.5f
/*
* This helper is set by CardView implementations.
* <p>
* Prior to API 17, canvas.drawRoundRect is expensive; which is why we need this interface
* to draw efficient rounded rectangles before 17.
* */
var sRoundRectHelper: RoundRectHelper? = null
fun calculateVerticalPadding(maxShadowSize: Float, cornerRadius: Float,
addPaddingForCorners: Boolean): Float {
return if (addPaddingForCorners) {
(maxShadowSize * SHADOW_MULTIPLIER + (1 - COS_45) * cornerRadius).toFloat()
} else {
maxShadowSize * SHADOW_MULTIPLIER
}
}
fun calculateHorizontalPadding(maxShadowSize: Float, cornerRadius: Float,
addPaddingForCorners: Boolean): Float {
return if (addPaddingForCorners) {
(maxShadowSize + (1 - COS_45) * cornerRadius).toFloat()
} else {
maxShadowSize
}
}
}
}
================================================
FILE: cardviewlibrary/src/main/res/drawable/green_bg.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<solid android:color="@color/color8DBEC4"></solid>
</shape>
================================================
FILE: cardviewlibrary/src/main/res/drawable/ic_launcher_background.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
================================================
FILE: cardviewlibrary/src/main/res/drawable/ic_launcher_foreground.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
================================================
FILE: cardviewlibrary/src/main/res/drawable/shape_round_orange_bg.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="999dp"/>
<solid android:color="#FF6F11"/>
</shape>
================================================
FILE: cardviewlibrary/src/main/res/values/attrs.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="startColor" format="reference|color"/>
<attr name="topDelta" format="float"/>
<!-- Selected Paint Color (color). -->
<attr name="endColor" format="reference|color"/>
<declare-styleable name="CardViewShadow">
<!-- Default Paint Color (color). -->
<attr name="startColor" />
<!-- Selected Paint Color (color). -->
<attr name="endColor" />
<attr name="topDelta" />
</declare-styleable>
</resources>
================================================
FILE: cardviewlibrary/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#FF6602</color>
<color name="colorPrimaryDark">#F66100</color>
<color name="colorAccent">#FF6602</color>
<color name="white">#ffffff</color>
<color name="black">@android:color/black</color>
<color name="colorFF6602">#FF6602</color>
<color name="colorEF5F00">#EF5F00</color>
<color name="transparent">@android:color/transparent</color>
<color name="color2B2B2B">#2B2B2B</color>
<color name="colorC3C3C3">#C3C3C3</color>
<color name="color8F8F8F">#8F8F8F</color>
<color name="colorE5E5E5">#E5E5E5</color>
<color name="colorF3F3F3">#F3F3F3</color>
<!--分割线颜色-->
<color name="colorDDDDDD">#DDDDDD</color>
<color name="colorFF1010">#FF1010</color>
<color name="colorEF0000">#EF0000</color>
<color name="color444444">#444444</color>
<color name="color3C3C3C">#3C3C3C</color>
<!--规范之外的颜色-->
<color name="color333333">#333333</color>
<color name="color666666">#666666</color>
<color name="colorE9E9E9">#E9E9E9</color>
<color name="color7C7B7B">#7C7B7B</color>
<color name="colorD8D8D8">#D8D8D8</color>
<color name="color999999">#999999</color>
<color name="color1F1F1F">#1F1F1F</color>
<color name="color111111">#111111</color>
<color name="color979797">#979797</color>
<color name="colorD4D4D4">#D4D4D4</color>
<color name="colorCC9900">#CC9900</color>
<color name="colorFEFBFB">#FEFBFB</color>
<color name="colorFF4F4F">#FF4F4F</color>
<color name="color008FEB">#008FEB</color>
<color name="color80000000">#80000000</color>
<color name="color50000000">#50000000</color>
<color name="colorF7F7F7">#F7F7F7</color>
<color name="color4F4F4F">#4F4F4F</color>
<color name="color55000000">#55000000</color>
<color name="colorCCCCCC">#CCCCCC</color>
<color name="colorFAFAFA">#FAFAFA</color>
<color name="color576F6F6F">#576F6F6F</color>
<color name="colorA4A4A4">#A4A4A4</color>
<color name="colorF8F8F8">#F8F8F8</color>
<color name="color515151">#515151</color>
<color name="color787878">#787878</color>
<color name="colorD9D9D9">#D9D9D9</color>
<color name="colorB9B9B9">#B9B9B9</color>
<color name="colorABABAB">#ABABAB</color>
<color name="colorB0B0B0">#B0B0B0</color>
<color name="colorFF3B30">#FF3B30</color>
<color name="color7F7F7F">#7F7F7F</color>
<color name="color969696">#969696</color>
<color name="color577699">#577699</color>
<color name="color8C8C8C">#8C8C8C</color>
<color name="colorF6F5F4">#F6F5F4</color>
<color name="color0F0F0F">#0F0F0F</color>
<color name="color17AA1C">#17AA1C</color>
<color name="color40B4B4B4">#40B4B4B4</color>
<color name="color959595">#959595</color>
<color name="colorCECECE">#CECECE</color>
<color name="colorEDEDEE">#EDEDEE</color>
<color name="color0E0E0E">#0E0E0E</color>
<color name="colorDCDCDC">#DCDCDC</color>
<color name="color4A4A4A">#4A4A4A</color>
<color name="color3D3D3D">#3D3D3D</color>
<color name="colorCDCDCD">#CDCDCD</color>
<color name="color808080">#808080</color>
<color name="colorF66100">#F66100</color>
<color name="colorFF8E44">#FF8E44</color>
<color name="color89A4C9">#89A4C9</color>
<color name="colorF3F3F5">#F3F3F5</color>
<color name="color191919">#191919</color>
<color name="colorF4F4F4">#F4F4F4</color>
<color name="color5378AB">#5378AB</color>
<color name="color9EA8EA">#9EA8EA</color>
<color name="colorFF8535">#FF8535</color>
<color name="color10FF8535">#10FF8535</color>
<color name="colorFFB63F">#FFB63F</color>
<color name="color818181">#818181</color>
<color name="color838383">#838383</color>
<color name="color959FA6">#959FA6</color>
<color name="color0f0f0f">#0f0f0f</color>
<color name="color3F3F3F">#3F3F3F</color>
<color name="colorFF552E">#FF552E</color>
<color name="color99000000">#99000000</color>
<color name="color66000000">#66000000</color>
<color name="color5A5A5A">#5A5A5A</color>
<color name="colorFFA467">#FFA467</color>
<color name="colorFF444444">#ff444444</color>
<color name="color73FF6602">#73FF6602</color>
<color name="colorE3E3EC">#E3E3EC</color>
<color name="color5B5B5B">#5B5B5B</color>
<color name="color7F4A90E2">#7F4A90E2</color>
<color name="color4990E2">#4990E2</color>
<color name="color6d6d6d">#6d6d6d</color>
<color name="colorFF5252">#FF5252</color>
<color name="color38197A">#38197A</color>
<color name="colorEECC76">#EECC76</color>
<color name="color1C0B3A">#1C0B3A</color>
<color name="color281744">#281744</color>
<color name="colorF0F0F0">#F0F0F0</color>
<color name="colorECB408">#ECB408</color>
<color name="colorDDA66F">#DDA66F</color>
<color name="color1A1A1A">#1A1A1A</color>
<color name="color14FFFFFF">#14FFFFFF</color>
<color name="ColorFCF5FA">#FCF5FA</color>
<color name="ColorF3ECE4">#F3ECE4</color>
<color name="colorFF1313">#FF1313</color>
<color name="color848484">#848484</color>
<color name="colorD0D0D0">#D0D0D0</color>
<color name="colorF7F4EA">#F7F4EA</color>
<color name="color727272">#727272</color>
<color name="colorFFE89C">#FFE89C</color>
<color name="colorFFD571">#FFD571</color>
<color name="colorFEDAE4">#FEDAE4</color>
<color name="colorE1E1E1">#E1E1E1</color>
<color name="colorFFAD44">#FFAD44</color>
<color name="color8DBEC4">#8DBEC4</color>
<color name="colorF6F6F6">#F6F6F6</color>
<color name="cardview_shadow_start_color">#D2d2d2</color>
<color name="cardview_shadow_end_color">#F6F6F6</color>
</resources>
================================================
FILE: cardviewlibrary/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">CardViewLibrary</string>
</resources>
================================================
FILE: cardviewlibrary/src/test/java/com/bigman/wmzx/cardviewlibrary/ExampleUnitTest.java
================================================
package com.bigman.wmzx.cardviewlibrary;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Tue Jul 10 15:07:19 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
================================================
FILE: gradle.properties
================================================
# 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
================================================
FILE: gradlew
================================================
#!/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 "$@"
================================================
FILE: gradlew.bat
================================================
@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
================================================
FILE: settings.gradle
================================================
include ':app', ':cardviewlibrary'
gitextract_hvc7vbzt/ ├── .gitattributes ├── .gitignore ├── .idea/ │ ├── gradle.xml │ ├── misc.xml │ └── runConfigurations.xml ├── LICENSE ├── README.md ├── build.gradle ├── cardviewlibrary/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── bigman/ │ │ └── wmzx/ │ │ └── cardviewlibrary/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── bigman/ │ │ │ └── wmzx/ │ │ │ └── cardviewlibrary/ │ │ │ └── library/ │ │ │ ├── CardView.kt │ │ │ ├── CardViewApi17Impl.kt │ │ │ ├── CardViewApi21Impl.kt │ │ │ ├── CardViewBaseImpl.java │ │ │ ├── CardViewDelegate.java │ │ │ ├── CardViewImpl.kt │ │ │ ├── RoundRectDrawable.java │ │ │ └── RoundRectDrawableWithShadow.kt │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── green_bg.xml │ │ │ ├── ic_launcher_background.xml │ │ │ ├── ic_launcher_foreground.xml │ │ │ └── shape_round_orange_bg.xml │ │ └── values/ │ │ ├── attrs.xml │ │ ├── colors.xml │ │ └── strings.xml │ └── test/ │ └── java/ │ └── com/ │ └── bigman/ │ └── wmzx/ │ └── cardviewlibrary/ │ └── ExampleUnitTest.java ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle
SYMBOL INDEX (53 symbols across 5 files)
FILE: cardviewlibrary/src/androidTest/java/com/bigman/wmzx/cardviewlibrary/ExampleInstrumentedTest.java
class ExampleInstrumentedTest (line 17) | @RunWith(AndroidJUnit4.class)
method useAppContext (line 19) | @Test
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewBaseImpl.java
class CardViewBaseImpl (line 13) | public class CardViewBaseImpl implements CardViewImpl {
method initStatic (line 17) | @Override
method initialize (line 60) | @Override
method createBackground (line 70) | private RoundRectDrawableWithShadow createBackground(Context context,
method updatePadding (line 77) | @Override
method onCompatPaddingChanged (line 87) | @Override
method onPreventCornerOverlapChanged (line 92) | @Override
method setBackgroundColor (line 98) | @Override
method getBackgroundColor (line 103) | @Override
method initialize (line 108) | @Override
method createBackground (line 119) | private RoundRectDrawableWithShadow createBackground(Context context, ...
method setRadius (line 126) | @Override
method getRadius (line 132) | @Override
method setElevation (line 137) | @Override
method getElevation (line 142) | @Override
method setMaxElevation (line 147) | @Override
method getMaxElevation (line 153) | @Override
method getMinWidth (line 158) | @Override
method getMinHeight (line 163) | @Override
method getShadowBackground (line 168) | private RoundRectDrawableWithShadow getShadowBackground(CardViewDelega...
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewDelegate.java
type CardViewDelegate (line 12) | public interface CardViewDelegate {
method setCardBackground (line 13) | void setCardBackground(Drawable drawable);
method getCardBackground (line 14) | Drawable getCardBackground();
method getUseCompatPadding (line 15) | boolean getUseCompatPadding();
method getPreventCornerOverlap (line 16) | boolean getPreventCornerOverlap();
method setShadowPadding (line 17) | void setShadowPadding(int left, int top, int right, int bottom);
method setMinWidthHeightInternal (line 18) | void setMinWidthHeightInternal(int width, int height);
method getCardView (line 19) | View getCardView();
FILE: cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/RoundRectDrawable.java
class RoundRectDrawable (line 30) | @RequiresApi(21)
method RoundRectDrawable (line 45) | public RoundRectDrawable(ColorStateList backgroundColor, float radius) {
method setBackground (line 54) | private void setBackground(ColorStateList color) {
method setPadding (line 59) | void setPadding(float padding, boolean insetForPadding, boolean insetF...
method getPadding (line 71) | float getPadding() {
method draw (line 75) | @Override
method updateBounds (line 94) | private void updateBounds(Rect bounds) {
method onBoundsChange (line 109) | @Override
method getOutline (line 115) | @Override
method setRadius (line 120) | void setRadius(float radius) {
method setAlpha (line 129) | @Override
method setColorFilter (line 134) | @Override
method getOpacity (line 139) | @Override
method getRadius (line 144) | public float getRadius() {
method setColor (line 148) | public void setColor(@Nullable ColorStateList color) {
method getColor (line 153) | public ColorStateList getColor() {
method setTintList (line 157) | @Override
method setTintMode (line 164) | @Override
method onStateChange (line 171) | @Override
method isStateful (line 185) | @Override
method createTintFilter (line 195) | private PorterDuffColorFilter createTintFilter(ColorStateList tint, Po...
FILE: cardviewlibrary/src/test/java/com/bigman/wmzx/cardviewlibrary/ExampleUnitTest.java
class ExampleUnitTest (line 12) | public class ExampleUnitTest {
method addition_isCorrect (line 13) | @Test
Condensed preview — 35 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (104K chars).
[
{
"path": ".gitattributes",
"chars": 66,
"preview": "# Auto detect text files and perform LF normalization\n* text=auto\n"
},
{
"path": ".gitignore",
"chars": 186,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n.i"
},
{
"path": ".idea/gradle.xml",
"chars": 687,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"GradleSettings\">\n <option name=\"linke"
},
{
"path": ".idea/misc.xml",
"chars": 2029,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"NullableNotNullManager\">\n <option nam"
},
{
"path": ".idea/runConfigurations.xml",
"chars": 564,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"RunConfigurationProducerService\">\n <o"
},
{
"path": "LICENSE",
"chars": 11323,
"preview": "Apache License\n Version 2.0, January 2004\n http://www.apache.org/licens"
},
{
"path": "README.md",
"chars": 1404,
"preview": "# CardviewFix 简书地址 [https://www.jianshu.com/p/8c8b2708bdb4]\n\n##### 原生的CardView虽然好,但是公司UI设计必须修改阴影颜色\n这个库是基于google官方库,所以基本属"
},
{
"path": "build.gradle",
"chars": 644,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n e"
},
{
"path": "cardviewlibrary/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "cardviewlibrary/build.gradle",
"chars": 848,
"preview": "apply plugin: 'com.android.library'\napply plugin: 'kotlin-android'\n\napply plugin: 'kotlin-android-extensions'\nandroid {\n"
},
{
"path": "cardviewlibrary/proguard-rules.pro",
"chars": 751,
"preview": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguar"
},
{
"path": "cardviewlibrary/src/androidTest/java/com/bigman/wmzx/cardviewlibrary/ExampleInstrumentedTest.java",
"chars": 768,
"preview": "package com.bigman.wmzx.cardviewlibrary;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationReg"
},
{
"path": "cardviewlibrary/src/main/AndroidManifest.xml",
"chars": 118,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"com.bigman.wmzx.cardviewlibrary\" />\n"
},
{
"path": "cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardView.kt",
"chars": 20062,
"preview": "package com.bigman.wmzx.customcardview.library\n\n/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed "
},
{
"path": "cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewApi17Impl.kt",
"chars": 845,
"preview": "package com.bigman.wmzx.customcardview.library\n\nimport android.content.Context\nimport android.content.res.ColorStateList"
},
{
"path": "cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewApi21Impl.kt",
"chars": 3871,
"preview": "package com.bigman.wmzx.cardviewlibrary.library\n\nimport android.content.Context\nimport android.content.res.ColorStateLis"
},
{
"path": "cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewBaseImpl.java",
"chars": 7396,
"preview": "package com.bigman.wmzx.cardviewlibrary.library;\n\nimport android.content.Context;\nimport android.content.res.ColorStateL"
},
{
"path": "cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewDelegate.java",
"chars": 546,
"preview": "package com.bigman.wmzx.cardviewlibrary.library;\n\nimport android.graphics.drawable.Drawable;\nimport android.view.View;\n\n"
},
{
"path": "cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/CardViewImpl.kt",
"chars": 1500,
"preview": "package com.bigman.wmzx.customcardview.library\n\nimport android.content.Context\nimport android.content.res.ColorStateList"
},
{
"path": "cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/RoundRectDrawable.java",
"chars": 6081,
"preview": "package com.bigman.wmzx.cardviewlibrary.library;\n\n\n\n\nimport android.content.res.ColorStateList;\nimport android.graphics."
},
{
"path": "cardviewlibrary/src/main/java/com/bigman/wmzx/cardviewlibrary/library/RoundRectDrawableWithShadow.kt",
"chars": 14069,
"preview": "package com.bigman.wmzx.customcardview.library\n\n\nimport android.content.res.ColorStateList\nimport android.content.res.Re"
},
{
"path": "cardviewlibrary/src/main/res/drawable/green_bg.xml",
"chars": 200,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:sha"
},
{
"path": "cardviewlibrary/src/main/res/drawable/ic_launcher_background.xml",
"chars": 5606,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:wi"
},
{
"path": "cardviewlibrary/src/main/res/drawable/ic_launcher_foreground.xml",
"chars": 1880,
"preview": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:aapt=\"http://schemas.android.com/aapt\"\n "
},
{
"path": "cardviewlibrary/src/main/res/drawable/shape_round_orange_bg.xml",
"chars": 214,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape android:shape=\"rectangle\" xmlns:android=\"http://schemas.android.com/apk/re"
},
{
"path": "cardviewlibrary/src/main/res/values/attrs.xml",
"chars": 531,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <attr name=\"startColor\" format=\"reference|color\"/>\n <attr nam"
},
{
"path": "cardviewlibrary/src/main/res/values/colors.xml",
"chars": 5727,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#FF6602</color>\n <color name=\"color"
},
{
"path": "cardviewlibrary/src/main/res/values/strings.xml",
"chars": 78,
"preview": "<resources>\n <string name=\"app_name\">CardViewLibrary</string>\n</resources>\n"
},
{
"path": "cardviewlibrary/src/test/java/com/bigman/wmzx/cardviewlibrary/ExampleUnitTest.java",
"chars": 409,
"preview": "package com.bigman.wmzx.cardviewlibrary;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example loca"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Tue Jul 10 15:07:19 CST 2018\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties",
"chars": 730,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "settings.gradle",
"chars": 35,
"preview": "include ':app', ':cardviewlibrary'\n"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the bigmanLau/CardviewFix GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 35 files (94.4 KB), approximately 25.3k tokens, and a symbol index with 53 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.