MissMyDearBear / ScreenShotTools

ScreenShotTools是一个Android长截图工具

Home Page:https://github.com/MissMyDearBear/ScreenShotTools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

写在前面

2017年的时候因项目需要整理了一篇关于长截图的文章。看到很多同学有留言,所以现在决定把它重新梳理一下,做成一个开源的库。

效果图

ScreenShotTools

ScreenShotTools是一个Android长截图工具。目的是轻松搞定常见的View截图功能。 目前功能有:

1. ScrollView的截图
2. RecyclerView的截图
3. WebView的截图
4. View的截图
5. 各截图提供拼接头部和尾部功能

使用方法:

gradle配置
  1. 在最外层的build.gradle中添加maven地址(已传入JCenter,本步骤可以忽略)
allprojects {
    repositories {
       ..
        maven { url 'https://dl.bintray.com/missmydearbear/maven' }
    }
}

  1. app目录下的build.gradle中添加
implementation "com.bear:ScreenShotTools:1.0"
Api
//1.只截传入的View
 fun takeCapture(context: Context, view: View, callBack: IScreenShotCallBack?) 
//2.拼接头部图片
 fun takeCapture(context: Context, view: View, topBitmap: Bitmap?, callBack: IScreenShotCallBack?) 
//3.拼接头部和底部图片
 fun takeCapture(
        context: Context,
        view: View,
        topBitmap: Bitmap?,
        bottomBitmap: Bitmap?,
        callBack: IScreenShotCallBack?
    ) 
//4. 拼接头部和底部图片,且传入图片的宽度
 fun takeCapture(
        context: Context,
        view: View,
        topBitmap: Bitmap?,
        bottomBitmap: Bitmap?,
        width: Int,
        callBack: IScreenShotCallBack?
    ) 

demo

以RecyclerView为例

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_recycler_view)
        tv.setOnClickListener {
            ScreenShotTools.instance.takeCapture(this, recycler_view, object : IScreenShotCallBack {
                override fun onResult(screenBitmap: ScreenBitmap?) {
                    //todo do your things
                }

            })
        }
        loadData()
    }

写在最后

具体使用效果可看本项目demo。欢迎大家提issu。

About

ScreenShotTools是一个Android长截图工具

https://github.com/MissMyDearBear/ScreenShotTools


Languages

Language:Kotlin 92.7%Language:Java 7.3%