xmlファイルをRelativeLayout
の背景イメージとして設定しようとしています。これを行うには、xmlをドロウアブルに変換する必要があります。drawableとしてXMLを使用しているときに「リサイクルビットマップを使用しようとしています」という例外が発生しました
これは私がやったです...
RelativeLayout content = (RelativeLayout) findViewById(R.id.background);
// "content" is the xml file (which is currently displayed), that I want to use as the background image.
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
content.setDrawingCacheEnabled(false);
Drawable d = new BitmapDrawable(getResources(), bitmap);
// Now I'm changing layouts to the one that has the Relative Layout of which I want to add the xml/drawable background.
mvf.setDisplayedChild(0);
// The layout of which I want to add the xml/drawable background.
(findViewById(R.id.root)).setBackground(d);
これらは私が取得していますエラーがあります。ここで
W/Bitmap: Called getWidth() on a recycle()'d bitmap! This is undefined behavior!
W/Bitmap: Called getHeight() on a recycle()'d bitmap! This is undefined behavior!
W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!
W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!
W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap [email protected]