我想问一下webview: 我无法在webview中捕获整页。我只能捕获屏幕上显示的视图,因为我想捕获整页。怎么样?
这是我的网页浏览:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
WebView.enableSlowWholeDocumentDraw();
}
setContentView(R.layout.main_activity);
final WebView webview = (WebView) findViewById(R.id.WebViewLayout);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(webview, url);
}
});
webview.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webview.setDrawingCacheEnabled(true);
webview.loadUrl("https://example.com");
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
Toast.makeText(this, "Bluetooth is not available",
Toast.LENGTH_LONG).show();
finish();
}
}
这是转换为位图
private void Print_BMP(){
Bitmap mBitmap = Bitmap.createBitmap(imageViewPicture.getDrawingCache());
int nMode = 0;
int nPaperWidth = 384;
if(width_58mm.isChecked())
nPaperWidth = 384;
if(mBitmap != null)
{
byte[] data = PrintPicture.POS_PrintBMP(mBitmap, nPaperWidth, nMode);
SendDataByte(Command.ESC_Init);
SendDataByte(Command.LF);
SendDataByte(data);
SendDataByte(PrinterCommand.POS_Set_PrtAndFeedPaper(30));
SendDataByte(PrinterCommand.POS_Set_Cut(1));
SendDataByte(PrinterCommand.POS_Set_PrtInit());
}
}
这适用于keylistener
private void KeyListenerInit() {
btnScanButton = (Button)findViewById(R.id.button_scan);
btnScanButton.setOnClickListener(this);
width_58mm = (RadioButton)findViewById(R.id.width_58mm);
width_58mm.setOnClickListener(this);
imageViewPicture = (WebView) findViewById(R.id.WebViewLayout);
imageViewPicture.setOnClickListener(this);
}
答案 0 :(得分:0)
根据需要捕捉,滚动,捕捉,重复。
然后在需要之后组合各个图像。
提供此功能的加载项浏览器工具似乎也以同样的方式工作。