|
1 | 1 | ### 跟miui一样的自动滚动截屏
|
2 | 2 |
|
3 |
| ->> 很久之前写过一篇长截屏的博客,不过很仓促,现在重新整理一下,绝对是你从没见过的长截屏方式 [android长截屏beta1](http://blog.csdn.net/qingchunweiliang/article/details/52248643) |
| 3 | +>> 很久之前写过一篇完全不同于其他长截屏方案的的博客,不过很仓促,现在重新整理一下 [android长截屏beta1](http://blog.csdn.net/qingchunweiliang/article/details/52248643) |
4 | 4 |
|
5 | 5 |
|
6 | 6 | #### 画
|
|
9 | 9 | * 手动调用`FrameLayout`的`draw`方法把`view`画到`bitmap`上
|
10 | 10 |
|
11 | 11 | ```java
|
12 |
| - Bitmap bitmap = Bitmap.createBitmap(container.getWidth(), container.getHeight(), Bitmap.Config.ARGB_8888); |
| 12 | +Bitmap bitmap = Bitmap.createBitmap(container.getWidth(), container.getHeight(), Bitmap.Config.ARGB_8888); |
13 | 13 | Canvas canvas = new Canvas(bitmap);
|
14 | 14 | container.draw(canvas);
|
15 | 15 |
|
@@ -169,7 +169,8 @@ container.draw(canvas);
|
169 | 169 | for (Bitmap bitmap : bitmaps) {
|
170 | 170 | h += bitmap.getHeight();
|
171 | 171 | }
|
172 |
| - Bitmap bitmap = Bitmap.createBitmap(container.getWidth(), h, Bitmap.Config.RGB_565); |
| 172 | + //如果你需要透明度或者对图片质量要求很高的话请使用Config.ARGB_8888 |
| 173 | + Bitmap bitmap = Bitmap.createBitmap(container.getWidth(), h, Bitmap.Config.RGB_565); |
173 | 174 | Canvas canvas = new Canvas(bitmap);
|
174 | 175 | for (Bitmap b : bitmaps) {
|
175 | 176 | canvas.drawBitmap(b, 0, 0, null);
|
@@ -200,9 +201,37 @@ container.draw(canvas);
|
200 | 201 | ```
|
201 | 202 | #### 最终效果
|
202 | 203 |
|
203 |
| - 左边是自动滚动的Listview,右边是停止截屏后的bitmap |
| 204 | + 左边是自动滚动的Listview,右边是停止截屏后的bitmap,可以看到完全没有拼接痕迹 |
| 205 | + |
| 206 | + |
204 | 207 | 
|
205 | 208 |
|
206 | 209 |
|
207 | 210 |
|
| 211 | + |
| 212 | + ```txt |
| 213 | + MIT License |
| 214 | +
|
| 215 | +Copyright (c) 2018 wanjian |
| 216 | +
|
| 217 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 218 | +of this software and associated documentation files (the "Software"), to deal |
| 219 | +in the Software without restriction, including without limitation the rights |
| 220 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 221 | +copies of the Software, and to permit persons to whom the Software is |
| 222 | +furnished to do so, subject to the following conditions: |
| 223 | +
|
| 224 | +The above copyright notice and this permission notice shall be included in all |
| 225 | +copies or substantial portions of the Software. |
| 226 | +
|
| 227 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 228 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 229 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 230 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 231 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 232 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 233 | +SOFTWARE. |
| 234 | +
|
| 235 | + |
| 236 | + ``` |
208 | 237 |
|
0 commit comments