|
1 | 1 | # IntensifyGridView
|
2 | 2 | 
|
3 | 3 |
|
4 |
| -# Sample |
| 4 | +# Usage |
| 5 | +- 省略布局(如QQ空间图片大于9张时最后一张的图片显示样式特殊),形式类型TextView的省略样式,可以指定省略位置(前,后,无) |
| 6 | +- 额外布局(如设置最大长度为9,额外布局为1,那么在长度小于等于9时会出现额外布局,大于等于9时额外布局消失) |
| 7 | +- 自动布局(根据设置的Block的尺寸进行自动布局,类似于`GridView`的`auto_fit`) |
| 8 | +- 设置间隙的宽度,以及多余间隙的位置(前留白,后留白,均分) |
| 9 | +- 设置间隙的drawable |
| 10 | +- 最大行数,或者最大长度 |
| 11 | +- 指定Block的形状(长方形和正方形) |
5 | 12 |
|
| 13 | +# Sample |
6 | 14 |
|
| 15 | +* 当autoFit为true时spanCount便会无效,这时spanCount是由blockWidth决定的,当autoFit为false时,需要设置spanCount来确定列数 |
7 | 16 |
|
8 | 17 | ``` xml
|
9 | 18 | <me.kareluo.intensify.gridview.IntensifyGridView
|
10 |
| - android:id="@+id/igv_grid" |
11 | 19 | android:layout_width="match_parent"
|
12 | 20 | android:layout_height="match_parent"
|
13 |
| - android:divider="@drawable/spacer_bar" |
14 | 21 | 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]"/> |
23 | 37 | ```
|
24 | 38 |
|
25 |
| -- 带有一个额外布局: |
| 39 | +``` java |
| 40 | +// Adapter 继承 IntensifyGridAdapter |
| 41 | +private class TestAdapter extends IntensifyGridAdapter<DemoViewHolder> { |
26 | 42 |
|
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 | +} |
42 | 88 | ```
|
43 | 89 |
|
| 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 | +``` |
44 | 107 |
|
0 commit comments