Skip to content

Commit f3f27b8

Browse files
committed
README
1 parent 00e4d6b commit f3f27b8

File tree

4 files changed

+101
-28
lines changed

4 files changed

+101
-28
lines changed

README.md

+90-27
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,107 @@
11
# IntensifyGridView
22
![预览](screenshot/merge.jpg)
33

4-
# Sample
4+
# Usage
5+
- 省略布局(如QQ空间图片大于9张时最后一张的图片显示样式特殊),形式类型TextView的省略样式,可以指定省略位置(前,后,无)
6+
- 额外布局(如设置最大长度为9,额外布局为1,那么在长度小于等于9时会出现额外布局,大于等于9时额外布局消失)
7+
- 自动布局(根据设置的Block的尺寸进行自动布局,类似于`GridView``auto_fit`
8+
- 设置间隙的宽度,以及多余间隙的位置(前留白,后留白,均分)
9+
- 设置间隙的drawable
10+
- 最大行数,或者最大长度
11+
- 指定Block的形状(长方形和正方形)
512

13+
# Sample
614

15+
* 当autoFit为true时spanCount便会无效,这时spanCount是由blockWidth决定的,当autoFit为false时,需要设置spanCount来确定列数
716

817
``` xml
918
<me.kareluo.intensify.gridview.IntensifyGridView
10-
android:id="@+id/igv_grid"
1119
android:layout_width="match_parent"
1220
android:layout_height="match_parent"
13-
android:divider="@drawable/spacer_bar"
1421
android:orientation="vertical"
15-
app:blockSize="match_parent"
16-
app:blockType="square"
17-
app:ellipsize="end"
18-
app:horizontalSpacing="1dp"
19-
app:maxLines="3"
20-
app:spacingGravity="share"
21-
app:spanCount="3"
22-
app:verticalSpacing="1dp" />
22+
android:divider="[color|drawable]"
23+
app:autoFit="[boolean]"
24+
app:blockSize="[match_parent|wrap_content|dimension]"
25+
app:blockWidth="[match_parent|wrap_content|dimension]"
26+
app:blockHeight="[match_parent|wrap_content|dimension]"
27+
app:blockType="[square|rectangle]"
28+
app:ellipsize="[none|start|end]"
29+
app:horizontalSpacing="[dimension["
30+
app:verticalSpacing="[dimension]"
31+
app:maxLines="[integer]"
32+
app:maxLength="[integer]"
33+
app:spacingGravity="[share|start|end]"
34+
app:spanCount="[integer]"
35+
app:extraCount="[single|integer]"
36+
app:spacer="[color|drawable]"/>
2337
```
2438

25-
- 带有一个额外布局:
39+
``` java
40+
// Adapter 继承 IntensifyGridAdapter
41+
private class TestAdapter extends IntensifyGridAdapter<DemoViewHolder> {
2642

27-
``` xml
28-
<me.kareluo.intensify.gridview.IntensifyGridView
29-
android:id="@+id/igv_grid"
30-
android:layout_width="match_parent"
31-
android:layout_height="match_parent"
32-
android:divider="@drawable/spacer_bar"
33-
android:orientation="vertical"
34-
app:blockSize="match_parent"
35-
app:blockType="square"
36-
app:ellipsize="end"
37-
app:extraCount="1"
38-
app:horizontalSpacing="1dp"
39-
app:spacingGravity="share"
40-
app:spanCount="5"
41-
app:verticalSpacing="1dp" />
43+
public TestAdapter(@NonNull IntensifyGridView intensifyGridView) {
44+
super(intensifyGridView);
45+
}
46+
47+
@Override
48+
protected void onBindCommonViewHolder(DemoViewHolder holder, int position) {
49+
// 绑定普通View
50+
holder.update(mResIds[position]);
51+
}
52+
53+
@Override
54+
protected void onBindEllipsizeViewHolder(DemoViewHolder holder, int position) {
55+
// 绑定省略布局View
56+
holder.update(position, getEllipsizeCount());
57+
}
58+
59+
@Override
60+
protected void onBindExtraViewHolder(DemoViewHolder holder, int position) {
61+
// 绑定额外布局View
62+
super.onBindExtraViewHolder(holder, position);
63+
}
64+
65+
@Override
66+
public DemoViewHolder onCreateCommonViewHolder(ViewGroup parent, int type) {
67+
// 创建普通Holder
68+
return new DemoViewHolder(new ImageItemView(getBaseContext()));
69+
}
70+
71+
@Override
72+
public DemoViewHolder onCreateEllipsizeViewHolder(ViewGroup parent) {
73+
// 创建省略布局Holder
74+
return new DemoViewHolder(new ImageItemView(getBaseContext()));
75+
}
76+
77+
@Override
78+
public DemoViewHolder onCreateExtraViewHolder(ViewGroup parent) {
79+
// 创建额外布局Holder
80+
return new DemoViewHolder(new ImageItemView(getBaseContext()));
81+
}
82+
83+
@Override
84+
public int getCount() {
85+
return mResIds.length;
86+
}
87+
}
4288
```
4389

90+
# License
91+
92+
``` license
93+
Copyright 2015 kareluo.
94+
95+
Licensed under the Apache License, Version 2.0 (the "License");
96+
you may not use this file except in compliance with the License.
97+
You may obtain a copy of the License at
98+
99+
http://www.apache.org/licenses/LICENSE-2.0
100+
101+
Unless required by applicable law or agreed to in writing, software
102+
distributed under the License is distributed on an "AS IS" BASIS,
103+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104+
See the License for the specific language governing permissions and
105+
limitations under the License.
106+
```
44107

app/src/main/java/me/kareluo/intensify/sample/MainActivity.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ protected void onBindCommonViewHolder(DemoViewHolder holder, int position) {
114114

115115
@Override
116116
protected void onBindEllipsizeViewHolder(DemoViewHolder holder, int position) {
117-
holder.update(position, getCount() - getItemCount());
117+
holder.update(position, getEllipsizeCount());
118+
}
119+
120+
@Override
121+
protected void onBindExtraViewHolder(DemoViewHolder holder, int position) {
122+
super.onBindExtraViewHolder(holder, position);
118123
}
119124

120125
@Override

app/src/main/res/layout/activity_demo_ellipsize.xml

+5
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@
1616
app:spanCount="3"
1717
app:verticalSpacing="1dp" />
1818

19+
<GridView
20+
android:layout_width="match_parent"
21+
android:numColumns="auto_fit"
22+
android:layout_height="wrap_content"/>
23+
1924
</LinearLayout>

screenshot/merge.jpg

-46.3 KB
Loading

0 commit comments

Comments
 (0)