Skip to content

Commit 9093401

Browse files
author
eericxu
committed
fix bug
1 parent 000f239 commit 9093401

60 files changed

Lines changed: 2733 additions & 2729 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
*.iml
2-
.gradle
3-
/local.properties
4-
/.idea
5-
.DS_Store
6-
/build
7-
/captures
8-
.externalNativeBuild
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild

LICENSE

Lines changed: 201 additions & 201 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 132 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,132 @@
1-
# CSLayout
2-
>1.一个支持所有View圆角的库 当然不仅仅是圆角 同时支持单独配置四个角圆角大小 四边阴影颜色及长度四边剪切长度
3-
4-
>2.扩展CSLayout 实现了一个共享元素的动画效果不同于Android官方的共享动画 支持圆角变换支持自定义传入参数 自定义Animator效果
5-
关于动画部分 查看 [https://www.jianshu.com/p/001e6cd66bf9](https://www.jianshu.com/p/001e6cd66bf9)
6-
7-
![圆角和阴影效果](/demoImg/1023565322.jpg)
8-
## 使用方式 ##
9-
10-
### 1 将cslibrary 添加到项目 ###
11-
[![](https://jitpack.io/v/XueMoMo/CSLayout.svg)](https://jitpack.io/#XueMoMo/CSLayout)
12-
Add it in your root build.gradle at the end of repositories:
13-
14-
allprojects {
15-
repositories {
16-
...
17-
maven { url 'https://jitpack.io' }
18-
}
19-
}
20-
Step 2. Add the dependency
21-
22-
dependencies {
23-
implementation 'com.github.XueMoMo:CSLayout:v1.1.1'
24-
}
25-
26-
### 2.1 布局文件中使用 CSLayout ###
27-
28-
<com.eericxu.cslibrary.CSLayout xmlns:android="http://schemas.android.com/apk/res/android"
29-
xmlns:app="http://schemas.android.com/apk/res-auto"
30-
android:layout_width="match_parent"
31-
android:layout_height="350dp"
32-
app:cs_corner_overlay="false"
33-
app:cs_clip="20dp"
34-
app:cs_corner="20dp"
35-
app:cs_shadow_size="15dp">
36-
<ImageView
37-
android:id="@+id/iv_cover"
38-
android:layout_width="match_parent"
39-
android:layout_height="match_parent"
40-
android:scaleType="centerCrop"
41-
android:src="@mipmap/img_4" />
42-
43-
44-
</com.eericxu.cslibrary.CSLayout>
45-
46-
### 2.2 自定义布局使用 CSHelper ###
47-
48-
val csHelper = CSHelper()
49-
constructor(context: Context?) : super(context)
50-
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
51-
csHelper.initAttr(this,context, attrs)
52-
}
53-
54-
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
55-
csHelper.initAttr(this,context, attrs)
56-
}
57-
var isDrawed = false
58-
override fun draw(canvas: Canvas?) {
59-
setLayerType(LAYER_TYPE_SOFTWARE,null)
60-
isDrawed = true
61-
csHelper.drawBefore(canvas,isInEditMode)
62-
super.draw(canvas)
63-
csHelper.drawAfter(canvas,isInEditMode)
64-
65-
}
66-
67-
override fun dispatchDraw(canvas: Canvas?) {
68-
if (isDrawed)
69-
super.dispatchDraw(canvas)
70-
else {
71-
csHelper.drawBefore(canvas,isInEditMode)
72-
super.dispatchDraw(canvas)
73-
csHelper.drawAfter(canvas,isInEditMode)
74-
}
75-
}
76-
77-
78-
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
79-
super.onSizeChanged(w, h, oldw, oldh)
80-
csHelper.onSizeChange(this,w, h)
81-
}
82-
### 3 属性对照 ###
83-
84-
<!-- *公共属性* -->
85-
<!--圆形-->
86-
<attr name="cs_circle" format="boolean" />
87-
<!--全部圆角半径-->
88-
<attr name="cs_corner" format="integer|dimension" />
89-
<!--针对各个角的圆角半径-->
90-
<attr name="cs_corner_top_left" format="integer|dimension" />
91-
<attr name="cs_corner_top_right" format="integer|dimension" />
92-
<attr name="cs_corner_bottom_left" format="integer|dimension" />
93-
<attr name="cs_corner_bottom_right" format="integer|dimension" />
94-
95-
<!-- 阴影-->
96-
<attr name="cs_shadow_size" format="integer|dimension" /> //阴影长度
97-
<attr name="cs_shadow_color" format="color" /> //阴影颜色
98-
//四边阴影大小
99-
<attr name="cs_shadow_size_left" format="integer|dimension" />
100-
<attr name="cs_shadow_size_top" format="integer|dimension" />
101-
<attr name="cs_shadow_size_right" format="integer|dimension" />
102-
<attr name="cs_shadow_size_bottom" format="integer|dimension" />
103-
104-
<!--裁切大小-->
105-
<attr name="cs_clip" format="integer|dimension" />
106-
//四边的裁切大小
107-
<attr name="cs_clip_left" format="integer|dimension" />
108-
<attr name="cs_clip_top" format="integer|dimension" />
109-
<attr name="cs_clip_right" format="integer|dimension" />
110-
<attr name="cs_clip_bottom" format="integer|dimension" />
111-
112-
<!--覆盖模式 or 裁切模式-->
113-
<attr name="cs_corner_overlay" format="boolean" />//false 为覆盖模式 默认覆盖模式 true 裁切模式
114-
<attr name="cs_corner_overlay_color" format="color" /> //覆盖模式时 覆盖的颜色
115-
116-
117-
# 注意: #
118-
119-
## 阴影是绘制在裁切的边缘上 #
120-
## 阴影长度按最大阴影大小绘制 通过调整绘制区域控制各边的阴影长度 ##
121-
所以要设置阴影需要先设置裁切大小
122-
123-
cs_clip >= cs_shadow_size
124-
cs_clip_left >= cs_shadow_size_left
125-
cs_clip_top >= cs_shadow_size_top
126-
cs_clip_right >= cs_shadow_size_right
127-
cs_clip_bottom >= cs_shadow_size_bottom
128-
129-
130-
131-
# [LICENSE](/LICENSE) #
132-
1+
# CSLayout
2+
>1.一个支持所有View圆角的库 当然不仅仅是圆角 同时支持单独配置四个角圆角大小 四边阴影颜色及长度四边剪切长度
3+
4+
>2.扩展CSLayout 实现了一个共享元素的动画效果不同于Android官方的共享动画 支持圆角变换支持自定义传入参数 自定义Animator效果
5+
关于动画部分 查看 [https://www.jianshu.com/p/001e6cd66bf9](https://www.jianshu.com/p/001e6cd66bf9)
6+
7+
![圆角和阴影效果](/demoImg/1023565322.jpg)
8+
## 使用方式 ##
9+
10+
### 1 将cslibrary 添加到项目 ###
11+
[![](https://jitpack.io/v/XueMoMo/CSLayout.svg)](https://jitpack.io/#XueMoMo/CSLayout)
12+
Add it in your root build.gradle at the end of repositories:
13+
14+
allprojects {
15+
repositories {
16+
...
17+
maven { url 'https://jitpack.io' }
18+
}
19+
}
20+
Step 2. Add the dependency
21+
22+
dependencies {
23+
implementation 'com.github.XueMoMo:CSLayout:v1.1.1'
24+
}
25+
26+
### 2.1 布局文件中使用 CSLayout ###
27+
28+
<com.eericxu.cslibrary.CSLayout xmlns:android="http://schemas.android.com/apk/res/android"
29+
xmlns:app="http://schemas.android.com/apk/res-auto"
30+
android:layout_width="match_parent"
31+
android:layout_height="350dp"
32+
app:cs_corner_overlay="false"
33+
app:cs_clip="20dp"
34+
app:cs_corner="20dp"
35+
app:cs_shadow_size="15dp">
36+
<ImageView
37+
android:id="@+id/iv_cover"
38+
android:layout_width="match_parent"
39+
android:layout_height="match_parent"
40+
android:scaleType="centerCrop"
41+
android:src="@mipmap/img_4" />
42+
43+
44+
</com.eericxu.cslibrary.CSLayout>
45+
46+
### 2.2 自定义布局使用 CSHelper ###
47+
48+
val csHelper = CSHelper()
49+
constructor(context: Context?) : super(context)
50+
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
51+
csHelper.initAttr(this,context, attrs)
52+
}
53+
54+
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
55+
csHelper.initAttr(this,context, attrs)
56+
}
57+
var isDrawed = false
58+
override fun draw(canvas: Canvas?) {
59+
setLayerType(LAYER_TYPE_SOFTWARE,null)
60+
isDrawed = true
61+
csHelper.drawBefore(canvas,isInEditMode)
62+
super.draw(canvas)
63+
csHelper.drawAfter(canvas,isInEditMode)
64+
65+
}
66+
67+
override fun dispatchDraw(canvas: Canvas?) {
68+
if (isDrawed)
69+
super.dispatchDraw(canvas)
70+
else {
71+
csHelper.drawBefore(canvas,isInEditMode)
72+
super.dispatchDraw(canvas)
73+
csHelper.drawAfter(canvas,isInEditMode)
74+
}
75+
}
76+
77+
78+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
79+
super.onSizeChanged(w, h, oldw, oldh)
80+
csHelper.onSizeChange(this,w, h)
81+
}
82+
### 3 属性对照 ###
83+
84+
<!-- *公共属性* -->
85+
<!--圆形-->
86+
<attr name="cs_circle" format="boolean" />
87+
<!--全部圆角半径-->
88+
<attr name="cs_corner" format="integer|dimension" />
89+
<!--针对各个角的圆角半径-->
90+
<attr name="cs_corner_top_left" format="integer|dimension" />
91+
<attr name="cs_corner_top_right" format="integer|dimension" />
92+
<attr name="cs_corner_bottom_left" format="integer|dimension" />
93+
<attr name="cs_corner_bottom_right" format="integer|dimension" />
94+
95+
<!-- 阴影-->
96+
<attr name="cs_shadow_size" format="integer|dimension" /> //阴影长度
97+
<attr name="cs_shadow_color" format="color" /> //阴影颜色
98+
//四边阴影大小
99+
<attr name="cs_shadow_size_left" format="integer|dimension" />
100+
<attr name="cs_shadow_size_top" format="integer|dimension" />
101+
<attr name="cs_shadow_size_right" format="integer|dimension" />
102+
<attr name="cs_shadow_size_bottom" format="integer|dimension" />
103+
104+
<!--裁切大小-->
105+
<attr name="cs_clip" format="integer|dimension" />
106+
//四边的裁切大小
107+
<attr name="cs_clip_left" format="integer|dimension" />
108+
<attr name="cs_clip_top" format="integer|dimension" />
109+
<attr name="cs_clip_right" format="integer|dimension" />
110+
<attr name="cs_clip_bottom" format="integer|dimension" />
111+
112+
<!--覆盖模式 or 裁切模式-->
113+
<attr name="cs_corner_overlay" format="boolean" />//false 为覆盖模式 默认覆盖模式 true 裁切模式
114+
<attr name="cs_corner_overlay_color" format="color" /> //覆盖模式时 覆盖的颜色
115+
116+
117+
# 注意: #
118+
119+
## 阴影是绘制在裁切的边缘上 #
120+
## 阴影长度按最大阴影大小绘制 通过调整绘制区域控制各边的阴影长度 ##
121+
所以要设置阴影需要先设置裁切大小
122+
123+
cs_clip >= cs_shadow_size
124+
cs_clip_left >= cs_shadow_size_left
125+
cs_clip_top >= cs_shadow_size_top
126+
cs_clip_right >= cs_shadow_size_right
127+
cs_clip_bottom >= cs_shadow_size_bottom
128+
129+
130+
131+
# [LICENSE](/LICENSE) #
132+

app/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/build
1+
/build

app/build.gradle

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
apply plugin: 'com.android.application'
2-
3-
apply plugin: 'kotlin-android'
4-
5-
apply plugin: 'kotlin-android-extensions'
6-
7-
android {
8-
compileSdkVersion 29
9-
defaultConfig {
10-
applicationId "com.eericxu.cslayout"
11-
minSdkVersion 14
12-
targetSdkVersion 29
13-
versionCode 1
14-
versionName "1.0"
15-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16-
}
17-
buildTypes {
18-
release {
19-
minifyEnabled false
20-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21-
}
22-
}
23-
buildToolsVersion '28.0.3'
24-
}
25-
26-
dependencies {
27-
implementation fileTree(include: ['*.jar'], dir: 'libs')
28-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
29-
implementation 'androidx.appcompat:appcompat:1.1.0'
30-
implementation 'androidx.recyclerview:recyclerview:1.1.0'
31-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
32-
testImplementation 'junit:junit:4.13'
33-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
34-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
35-
implementation project(':cslibrary')
36-
implementation 'com.github.bumptech.glide:glide:4.11.0'
37-
implementation 'androidx.palette:palette:1.0.0'
38-
}
1+
apply plugin: 'com.android.application'
2+
3+
apply plugin: 'kotlin-android'
4+
5+
apply plugin: 'kotlin-android-extensions'
6+
7+
android {
8+
compileSdkVersion 29
9+
defaultConfig {
10+
applicationId "com.eericxu.cslayout"
11+
minSdkVersion 14
12+
targetSdkVersion 29
13+
versionCode 1
14+
versionName "1.0"
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
buildToolsVersion '28.0.3'
24+
}
25+
26+
dependencies {
27+
implementation fileTree(include: ['*.jar'], dir: 'libs')
28+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
29+
implementation 'androidx.appcompat:appcompat:1.1.0'
30+
implementation 'androidx.recyclerview:recyclerview:1.1.0'
31+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
32+
testImplementation 'junit:junit:4.13'
33+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
34+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
35+
implementation project(':cslibrary')
36+
implementation 'com.github.bumptech.glide:glide:4.11.0'
37+
implementation 'androidx.palette:palette:1.0.0'
38+
}

0 commit comments

Comments
 (0)