私はアンドロイドに取り組んでいます。スクリーンショットをキャプチャする次のコードがあります。あなたのルートのレイアウトを設定するスクリーンショットは空白です:アンドロイド?
:私の問題は、それがゼロキロバイトのファイルを作成することです
private void getScreen()
{
View content = findViewById(R.id.layoutroot);
Bitmap bitmap = content.getDrawingCache();
File file = new File("/sdcard/test.png");
try
{
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
:
View content = findViewById(R.id.layoutroot);
content.setDrawingCacheEnabled(true);
機能レンダリングされたビューを取得します。何が問題なの?