在 Android 程序中實現自動的屏幕截屏功能
screenshot-tests-for-android 是來自 非死book 的一個 Android 開發包,用于在 Android 程序中實現自動的屏幕截屏功能。
示例代碼:
public class MyTests {
@Test
public void doScreenshot() {
/*
* Create and set up your view some how. This might be inflating,
* or creating from a view class. You might want to set properties
* on the view.
*/
View view = mLayoutInflater.inflate(R.layout.my_layout, null, false);
/*
* Measure and layout the view. In this example we give an exact
* width but all the height to be WRAP_CONTENT.
*/
ViewHelpers.setupView(view)
.setExactWidthDp(300)
.layout();
/*
* Take the actual screenshot. At the end of this call the screenshot
* is stored on the device, and the gradle plugin takes care of
* pulling it and displaying it to you in nice ways.
*/
Screenshot.snap(view)
.record();
}
} 本文由用戶 iamjohnli 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!