Skip to content

Commit 154434c

Browse files
author
uis
committed
新建module
1 parent 9de4db4 commit 154434c

16 files changed

Lines changed: 260 additions & 144 deletions

File tree

README-StackLayout.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# StackLayout
2+
**A swipe ViewGroup that supports left and right slide.**
3+
4+
**层叠View支持手势左右滑动,自动轮播,过渡动画**
5+
6+
1.onMeasure通过StackAdapter适配器取到itemView加入到StackLayaout容器
7+
8+
onMeasure() through stackAdapter add view to StackLayout
9+
10+
2.onLayout取到childView按照层叠布局
11+
12+
onLayout() get child view layout stack ui
13+
14+
3.onInterceptTouchEvent处理手势支持子View及Velocity
15+
16+
onInterceptTouchEvent() support child view gesture
17+
18+
4.onTouchEvent处理手势,释放后播放动画平滑过渡
19+
20+
onTouchEvent() swipe animation,when release recover animation
21+
22+
#### Captures
23+
24+
![效果图]()
25+
26+
### Use
27+
implementation 'com.uis:stacklayout:0.3.4'
28+
29+
*Name*| *Descript*|*Value*
30+
-----|--------|---
31+
stackSpace|间距(space)|默认值(default):10dp
32+
stackEdge|边界距离(edge)|默认值(default):10dp
33+
stackZoomX|x方向缩放(x zoom)| 0<x<=1,1表示等间距,默认值(default):1
34+
stackPadX|x方向偏移(x padding)|表示偏移间距,默认值:0
35+
stackPadX|PadX*(Size-1) < Space|PadX优先级高于ZoomX
36+
stackZoomY|y方向缩放(y zoom)| 0<y<=1,1表示和顶层等高度,默认值:0.9
37+
stackLooper|自动轮播(looper)|false/true
38+
stackSize|层叠数量(stack size)|3
39+
stackEdgeModel|层叠位置(stack model)|left/right
40+
41+
```
42+
<?xml version="1.0" encoding="utf-8"?>
43+
<com.uis.stackview.StackLayout xmlns:android="http://schemas.android.com/apk/res/android"
44+
xmlns:stack="http://schemas.android.com/apk/res-auto"
45+
android:id="@+id/stacklayout"
46+
android:layout_width="match_parent"
47+
android:layout_height="wrap_content"
48+
stack:stackSpace="5dp"
49+
stack:stackEdge="20dp"
50+
stack:stackZoomX="0.1"
51+
stack:stackZoomY="0.1"
52+
stack:stackLooper = "false"
53+
stack:stackSize = "5"
54+
stack:stackEdgeModel = "left">
55+
</com.uis.stackview.StackLayout>
56+
```
57+
58+
```
59+
stackViewLayout.setStackLooper(true);
60+
stackViewLayout.setAdapter(new StackLayout.StackAdapter() {
61+
@Override
62+
public View onCreateView(ViewGroup parent) {
63+
return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_fresco_layout,null);
64+
}
65+
66+
@Override
67+
public void onBindView(View view, int position) {
68+
SimpleDraweeView dv = view.findViewById(R.id.imageView);
69+
DraweeController controller = Fresco.newDraweeControllerBuilder()
70+
.setUri(Uri.parse(dataList.get(position).getMapImageUrl()))
71+
.setTapToRetryEnabled(true)
72+
.setOldController(dv.getController())
73+
.build();
74+
dv.setController(controller);
75+
}
76+
77+
@Override
78+
public int getItemCount() {
79+
return dataList.size();
80+
}
81+
82+
@Override
83+
public void onItemDisplay(int position) {
84+
Log.e("xx","display = " + position);
85+
}
86+
87+
@Override
88+
public void onItemClicked(int position) {
89+
Log.e("xx","clicked = " + position);
90+
stackViewLayout.setStackLooper(false);
91+
stackViewLayout.setPosition(position+3);
92+
}
93+
});
94+
stackViewLayout.setPosition(10);//指定位置
95+
```
96+
97+
### License
98+
99+
Copyright 2018, uis
100+
101+
Licensed under the Apache License, Version 2.0 (the "License");
102+
you may not use this file except in compliance with the License.
103+
You may obtain a copy of the License at
104+
105+
http://www.apache.org/licenses/LICENSE-2.0
106+
107+
Unless required by applicable law or agreed to in writing, software
108+
distributed under the License is distributed on an "AS IS" BASIS,
109+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
110+
See the License for the specific language governing permissions and
111+
limitations under the License.

README.md

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
11
# StackViewLayout
2-
**A swipe ViewGroup that supports left and right slide.**
3-
4-
**层叠View支持手势左右滑动,自动轮播,过渡动画**
5-
6-
1.onMeasure通过StackAdapter适配器取到itemView加入到StackLayaout容器
7-
8-
onMeasure() through stackAdapter add view to StackLayout
9-
10-
2.onLayout取到childView按照层叠布局
11-
12-
onLayout() get child view layout stack ui
13-
14-
3.onInterceptTouchEvent处理手势支持子View及Velocity
15-
16-
onInterceptTouchEvent() support child view gesture
17-
18-
4.onTouchEvent处理手势,释放后播放动画平滑过渡
19-
20-
onTouchEvent() swipe animation,when release recover animation
21-
22-
#### Captures
2+
#### Captures
233

244
![效果图]()
255

@@ -37,62 +17,6 @@ stackZoomY|y方向缩放(y zoom)| 0<y<=1,1表示和顶层等高度,默认值
3717
stackLooper|自动轮播(looper)|false/true
3818
stackSize|层叠数量(stack size)|3
3919
stackEdgeModel|层叠位置(stack model)|left/right
40-
41-
```
42-
<?xml version="1.0" encoding="utf-8"?>
43-
<com.uis.stackview.StackLayout xmlns:android="http://schemas.android.com/apk/res/android"
44-
xmlns:stack="http://schemas.android.com/apk/res-auto"
45-
android:id="@+id/stacklayout"
46-
android:layout_width="match_parent"
47-
android:layout_height="wrap_content"
48-
stack:stackSpace="5dp"
49-
stack:stackEdge="20dp"
50-
stack:stackZoomX="0.1"
51-
stack:stackZoomY="0.1"
52-
stack:stackLooper = "false"
53-
stack:stackSize = "5"
54-
stack:stackEdgeModel = "left">
55-
</com.uis.stackview.StackLayout>
56-
```
57-
58-
```
59-
stackViewLayout.setStackLooper(true);
60-
stackViewLayout.setAdapter(new StackLayout.StackAdapter() {
61-
@Override
62-
public View onCreateView(ViewGroup parent) {
63-
return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_fresco_layout,null);
64-
}
65-
66-
@Override
67-
public void onBindView(View view, int position) {
68-
SimpleDraweeView dv = view.findViewById(R.id.imageView);
69-
DraweeController controller = Fresco.newDraweeControllerBuilder()
70-
.setUri(Uri.parse(dataList.get(position).getMapImageUrl()))
71-
.setTapToRetryEnabled(true)
72-
.setOldController(dv.getController())
73-
.build();
74-
dv.setController(controller);
75-
}
76-
77-
@Override
78-
public int getItemCount() {
79-
return dataList.size();
80-
}
81-
82-
@Override
83-
public void onItemDisplay(int position) {
84-
Log.e("xx","display = " + position);
85-
}
86-
87-
@Override
88-
public void onItemClicked(int position) {
89-
Log.e("xx","clicked = " + position);
90-
stackViewLayout.setStackLooper(false);
91-
stackViewLayout.setPosition(position+3);
92-
}
93-
});
94-
stackViewLayout.setPosition(10);//指定位置
95-
```
9620

9721
### License
9822

demo/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ dependencies {
3030
implementation 'com.google.code.gson:gson:2.8.5'
3131
implementation "androidx.viewpager:viewpager:${androidx}"
3232
implementation 'com.facebook.fresco:fresco:2.2.0'
33-
implementation 'com.uis:stacklayout:0.3.4'
33+
implementation project(':stackviewlayout')
3434
implementation project(':stacklayout')
3535
}

demo/src/main/res/layout/item_layout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
android:layout_width="match_parent"
55
android:background="@drawable/default_back"
6-
android:layout_height="wrap_content">
6+
android:layout_height="match_parent">
77
<com.makeramen.roundedimageview.RoundedImageView
88
android:id="@+id/imageView"
99
android:layout_width="match_parent"

demo/src/main/res/layout/stack_left.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
stack:stackAspectRatio="2"
88
stack:stackPaddingX="15dp"
99
stack:stackOffsetX="2dp"
10-
stack:stackPaddingY="20dp"
11-
stack:stackOffsetY="5dp"
10+
stack:stackPaddingY="10dp"
11+
stack:stackOffsetY="3dp"
1212
stack:stackEdge="10dp"
1313
stack:stackSize = "3"
14-
stack:stackModel="right">
14+
stack:stackAutoPlay="false"
15+
stack:stackModel="left">
1516
</com.uis.stackviewlayout.StackViewLayout>

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':demo', ':stacklayout'
1+
include ':demo','stacklayout',':stackviewlayout'

stacklayout/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,4 @@ android {
2020
}
2121
}
2222

23-
dependencies{
24-
compileOnly "androidx.appcompat:appcompat:${androidx}"
25-
}
26-
2723
//apply from: '../../bintray.gradle'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.uis.stackviewlayout">
2+
package="com.uis.stackview">
33
</manifest>

0 commit comments

Comments
 (0)